Syntax highlighting is a sysadmin’s dream, it allows you to code more efficiently or easily parse through relevant information in config files. To get vim syntax highlighting to work in Lenny, you first need to install vim – as the base version (vim-tiny) does not support syntax highlighting.
# aptitude install vim
Then edit /etc/vim/vimrc and go to line 20 and remove the quotation in front of ‘syntax on’ so it looks like this:
# vi /etc/vim/vimrc
" Vim5 and later versions support syntax highlighting. Uncommenting the next " line enables syntax highlighting by default. syntax on " If using a dark background within the editing area and syntax highlighting " turn on this option as well
Finally save by hitting ‘:’ and type ‘x’ then enter. (There are many ways to save and quit in vim, such as replacing the ‘x’ with ‘wq’ or just simply hitting ‘ZZ’)
This is useful when commenting out (or in) blocks of code/text in a file.
Move the cursor to the first line you wish to comment out.
Press shift - v to begin block selection mode. The bottom of the screen will say:
-- VISUAL LINE --
Press down arrow to select the text you wish to comment out. When finished, press : (colon)
The bottom of the screen will change to:
:'<,'>
Append the search and replace statement (replace the beginning of the line – nothing – with a # symbol):
:'<,'>s/^/#
To comment in – or uncomment blocks use this statement (replace the # symbol at the beginning with nothing):
:'<,'>s/^#//