> TehRealNexGen wrote:
> I you have a bunch of un-indented code, how would you go about
> formatting the whole lot in one go? Auto-indenting loops etc…
Highlight the section you wish to re-indent with the ‘v’ (by character) or
‘V’ (by line) and movement keys
press ‘=’
Done!!
I often just do the entire file, which is:
ggVG=
basically, ‘=’ fixes the indentation.
autocompletion and other fun things are discussed in much detail at the vim
homepage (http://vim.org).
I’ve been using vim for many years, and wish I could have it all the time
when I type. yzis (kde ‘workalike’ for vim is nice, but not there yet. gvim
is great for use in the gui environment, and vim is just great everywhere!
No, you don’t have to think differently… {Grin} we already know you do,
since you use vim.
I’d suggest reading (or at least perusing) the VIM book found at the vim
site, as it discusses many things in more detail. Some of it’s heavy reading
though… Skim it at least.
ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf
Much Documentation:
http://www.vim.org/docs.php
Feel free to email me or post here (if “they” allow it) if you have questions.
LittleRedRooster covered most of your other questions very well.
I use the following line at the bottom of most of my text files to specify
the desired tabstop widths. This prevents me from bothering anyone else with
my indent choices, and makes it easy to adjust if needed.
// vim:tabstop=2:shiftwidth=2:softtabstop=2:
/* vim:tabstop=2:shiftwidth=2:softtabstop=2: */
; vim:tabstop=2:shiftwidth=2:softtabstop=2:
vim:tabstop=2:shiftwidth=2:softtabstop=2:
Yes, I like 2 space indents. Notice the ‘remark’ indicators on the left… I
just delete the lines which aren’t proper for the type of file I’m
editing, save and reload the file and the tabs are fixed. If you like 4 space
indents, change all the '2’s to '4’s. And so on.
You can put any number of vim config commands in something like this, so
things can be adjusted on the fly, for various files as needed.
Items of note:
the vim :help is amazingly well written and very useful
gvim allows you to use the mouse to use many commands if you
haven’t yet committed them all to memory
The VIM.org home page is your friend
The VIM manual (above) is great.
(‘expandtabs’ can ruin your day if you’re editing Makefiles!! {Grin} )
Loni
–
L R Nix
lornix@lornix.com