Samstag, 19. Juli 2008

Vim tip: soft textwidth for source code – highlight column 80

When editing source code in Vim I want to have a soft limit on 80 columns. I try to generally format code to fit this convention, but with the possibility to escape it if it gets too ugly. That's why I wouldn't :set textwidth=80. Instead set an additional syntax highlighting rule, by adding to your .vimrc:

" Highlight column 80
match CursorColumn /\%80v./

This adds to an existing syntax highlighting, so you can keep your existing highlighting or file type settings as they are.

See :help \%v for an explanation. See also Vim Tip #810 or #1523.

link (0 Kommentare)   ... comment

Thema: Vim