Retab files using vim
Sunday, November 2nd, 2008Use 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
Jing Xue’s Weblog

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
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…
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.
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.
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!
[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
http://www.vim.org/scripts/script.php?script_id=102
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.
'gf' actually supports opening any URL under the cursor, not only a local file path. For example, while the cursor is over "http://www.yahoo.com", typing 'gf' would open the html code for the Yahoo home page in Vim.
I have always used
:e #
to switch back and forth between two buffers, but evidently CTRL-^ is quicker.