Archive for the ‘vim’ Category

Retab files using vim

Sunday, November 2nd, 2008

Use tabs as much as possible:
vim -u NONE -c "set noet" -c 'retab! 4' -c wq filename
Use spaces as much as possible:
vim -u NONE -c "set et" -c 'retab! 4' -c wq filename

Eclipse + Vim = Eclim

Wednesday, October 22nd, 2008

I tried Eclim some time last year. I thought the idea of tackling the eclipse/vim-integration situation from a completely different angle was very clever, but the implementation wasn’t quite there. I couldn’t even get through the installation. more…

toggle options more efficiently

Tuesday, January 27th, 2004

One useful yet often overlooked way to toggle an option is
:set {option}!

The good thing about it is you don’t have to figure out whether to use “no” in front of the option name. E.g., You can keep doing “set wrap!” (ideally with command history), instead of keeping jumping back and forth between “set wrap” and “set nowrap”. Also when you want to map this command, only one mapping is necessary.

About marks

Tuesday, January 13th, 2004

An exerpt from dicsucssion thread “any way to highlight a mark?” on the vim user list.

Will Fiveash started the thread by asking how to see marks on left hand side of a window. A couple of users pointed him to the showmarks plugin, which is the best mark plugin so far, but with one caveat that any mark made on line 1 isn’t shown. Salman Halim pointed out the reason:

“There is no way to remove marks in Vim; the script simulates the removal
of a mark by setting it to line 1 and just not displaying signs for any
marks that map to line 1. Not a bug; more a way to allow the user to not
be stuck looking at marks that they don’t find relevant.”

Tim Chase then proposed that marks could be removed by removing the line bearing the mark and restoring the line. Antoine J. Mechelynck also proposed to create a new line, move the mark there, and delete the line along with the mark. He also pointed out that the ‘modified’ status can be saved and restored around either methods him and Chase proposed to avoid the buffer being marked modified.

As an (almost) conclusion to this discussion, Charles E. Cambell, Jr. posted a patch that actually implements a ‘markclear’ function.

Intellisense in Vim – Finally!

Monday, January 12th, 2004

If you are both a Vimmer who can’t live without ‘h,j,k,l’, and a Java programmer who has always missed the nice intellisense in all those IDE’s, now you can have both! There are things left desirable for sure, but the Intellisense for Vim rocks already with the initial 1.0 version!

A modified DirDiff plugin

Monday, January 12th, 2004

[Edit 01/12/2004] William Lee uploaded 1.0.1 at the link below on 2003-10-29 that seems to have fixed the bug. The latest version is 1.0.2 now.
The DirDiff plugin(1.0) I downloaded from
doesn’t seem to replace the path separators for files in sub directories (i.e. not directly under the directories being diff’ed).

I hacked it a bit to make it work. Still trying to contact William Lee, the original author…

See below for the patch for 1.0.

  1. 688,689c688,691
  2. < function! Copy(fileFrom, fileTo)
  3. < echo "Copy from " . a:fileFrom . " to " . a:fileTo
  4. ---
  5. > function! Copy(fileFromOrig, fileToOrig)
  6. > let fileFrom = substitute(a:fileFromOrig, '/', s:sep, 'g')
  7. > let fileTo = substitute(a:fileToOrig, '/', s:sep, 'g')
  8. > echo "Copy from " . fileFrom . " to " . fileTo
  9. 701c703
  10. < let copycmd = copycmd . " "".a:fileFrom."" "".a:fileTo."""
  11. ---
  12. > let copycmd = copycmd . " "".fileFrom."" "".fileTo."""
  13. 709c711
  14. < let copydircmd = copydircmd . " "".a:fileFrom."" "".a:fileTo."""
  15. ---
  16. > let copydircmd = copydircmd . " "".fileFrom."" "".fileTo."""
  17. 712c714
  18. < if (isdirectory(a:fileFrom))
  19. ---
  20. > if (isdirectory(fileFrom))
  21. 718c720
  22. < echo "Can't copy from " . a:fileFrom . " to " . a:fileTo
  23. ---
  24. > echo "Can't copy from " . fileFrom . " to " . fileTo
  25. 742,743c744,746
  26. < function! Delete(fileFrom)
  27. < echo "Deleting from " . a:fileFrom
  28. ---
  29. > function! Delete(fileFromOrig)
  30. > let fileFrom = substitute(a:fileFromOrig, '/', s:sep, 'g')
  31. > echo "Deleting from " . fileFrom
  32. 751c754
  33. < if (isdirectory(a:fileFrom))
  34. ---
  35. > if (isdirectory(fileFrom))
  36. 773c776
  37. < let delcmd = delcmd ." "".a:fileFrom."""
  38. ---
  39. > let delcmd = delcmd ." "".fileFrom."""
  40. 776c779
  41. < echo "Can't delete " . a:fileFrom
  42. ---
  43. > echo "Can't delete " . fileFrom

The power of ‘gf’

Monday, December 22nd, 2003

‘gf’ actually supports opening any URL under the cursor, not only a local file path. For example, while the cursor is over “”, typing ‘gf’ would open the html code for the Yahoo home page in Vim.

open a file name under cursor

Tuesday, December 16th, 2003
  1. ctrl-w f
  2. :h ctrl-w_f

Show the non-printable characters

Tuesday, November 25th, 2003
  1. :h list
  2. :h listchars

quick buffer switching

Tuesday, November 4th, 2003

I have always used
:e #
to switch back and forth between two buffers, but evidently CTRL-^ is quicker.