Thu, 24 Jan 2008

Tabs CodingGuidelines and Vim

vimrc settings

After almost 3 years using Vim as my preferred text editor, I continue to learn and to find tips and tricks I didn't see before. I imagine that to become really involved in any software and to really know most of its potentiality, one should become an active membre of its community, through forums, mailing lists, IRC ...

Today, I found out how to make tabulations visible, so, from now on, I can easily see if any source I'm editing isn't following our Coding Guidelines about whitespaces.

Here is the .vimrc settings:

  • set listchars=tab:.\ : listchars consists of a comma separated list of string settings. The string setting that interests me is tab, which consists of 2 characters to be used to show a tab. The first one is used once to mark the start of the space occupied by the tab, the second is repeated to fill the remaining spaces. Note that, here, my second character is not a backslash, but a space. It needed to be escaped, that's why you see a backslash character here. My tabs are now showing as a dot followed by spaces, so I can count the number of tabs by counting the number of dots.
  • hi SpecialKey guifg=#224488 guibg=#002266: But, I need to make a visual difference between a tab and any dots followed by blanks. For this purpose, I've added a special highlighting for the SpecialKey family, for them to have another background-color. (For this, I edited Vim71/colors/darkblue.vim, as darkblue is the only colorset I use.)
  • set list: This is the clue for showing tabs. Unfortunately, this option made one of my preferred vim setting inactive: the linebreak option which is not used when the list option is on, according to the documentation.

And here's how it sounds :
Screenshots of my Vim screen, distinguishing tabs

posté le: 13:16 | path: /data/web | permalien
Septembre 2010
Dim Lun Mar Mer Jeu Ven Sam
     
   

Malagasy miray
About

DotMG's joblog

Work hard at whatever you do. (Ecc. 9. 10a. CEV)
Valid XHTML 1.0 Transitional   Valid CSS!   Powered by blosxom 2.0