Virtually the best blog on the web!
Posts tagged VIM
Tabbing Tips and Towers Hanoi in VIM
Aug 3rd
A few random VIM tips, that I gave out recently
- Retabbing
- You can change the tab width with
:set ts. To have the tabs expanded, use:set expandtab, but this will only expand tabs from now on. To expand all the existing tabs do:retab - Show tabs
- Sometimes, you may want to see the tabs in your document with
:set list - Selective expansion of tabs
- You may not want to expand tabs in
Makefiles, and in particular directories like linux source directory. This can be done with the following function.function! SetTabbing() let _curdir = expand("%:p:h") let _curfile = expand("%:t") if _curdir =~ ".*linux.*" || _curdir =~ "/globus.*" || _curfile =~ ".*PROJECT2.*" set ts=8 set noexpandtab else set ts=4 set sw=4 set expandtab endif if _curfile =~ "Makefile" || _curfile =~ "makefile" || _curfile =~ ".*\.mk" set noexpandtab endif endfunction - Solving Towers of Hanoi in VIM
- Well, this is not really useful for anything other than for showing some VIM machismo
Download it from my website, and execute it as follows:
open the script :source % :call Hanoi(odd_number) # e.g. call Hanoi(3)
That’s all for today !