First, a note: tw
and textwidth
are the same thing (tw
is just the abbreviated name, variables generally have a long and short form) so you only need one of those first two lines in any case.
I suspect what you're really looking for is what I was looking for earlier, which is: how to keep settings specific to various file types. It actually gets fairly complicated because some settings (like textwidth
) are what vim calls "local to buffer", and others (like wrap
) are "local to window". The difference boils down to what happens if you (for example) run vim foo.txt
and then use :split
to get two windows viewing foo.txt
. There is now one buffer, hence one textwidth
, for foo.txt
, but there are two windows, hence two wrap
s.
Until you start using this feature for things, though, you probably just want to try out the suggestions in http://vim.wikia.com/wiki/VimTip1510 for making each setting depend on what filetype
is set to. Editing a file named foo.py
will use the Python settings, because vim automatically sets filetype=python
for files whose name ends in .py
. You can manually set the file type (:set filetype=whatever
) if the file name suffix is unknown or ambiguous (e.g., when editing file zog
which has no suffix at all but is actually a shell script, you can manually :set filetype=sh
), and there is a lot of other info you can find on making vim automatically recognize particular file types.
(Another side note: I don't agree with their setting tabstop=4
; I use softtabstop=4
and smarttabs
and expandtabs
so that I get nothing but spaces in my *.py files. This avoids the fight over whether tabs are placed at every 4 or 8 columns. :-) )
As for highlighting long lines in general, see http://vim.wikia.com/wiki/Highlight_long_lines for an explanation of what you're doing now, and why it's obsoleted if you have vim 7.3. See also vim-80-column-layout-concerns.