Vim Indentation [SOLVED]
I've been using Vim for a while, and I love it with all my heart. At work, however, the terminal sucks (X-Win for remote login from a Windows machine), so Vim looks horrible. Therefore, I've been using Emacs.
In Emacs, lines will automatically indent themselves to the proper length, and a closing bracket will automatically fall back to where it should be.
So basically, I'm curious if this can be done in Vim. I've checked Vim Tips and the FAQ and I see nothing. But when I was typing something at home this morning, I realized how much I miss this feature.
So yeah...does anyone know if it's possible?
should get you going
will list all the possible vim features (including some that can set or modify the window, might make VIM usable at work.
The Vim Cookbook is a great reference for random vim tips and tricks.
The smartindent might not meet your needs exactly, I just tried it on some C sytle formatting (with a .c file loaded) from scratch (ie, no .vim file specified) this might not work correctly. The easiest way to tell if Vim has properly identified you file is to turn syntax highlighting on
(if this turn up nothing, save the file and open it, also make sure you have installed the vim-rt package) this autodetection of filetype is done by filename extentions (not perfect, but they are all filetype/text-plain...) so be aware that custom extensions might throw it.
EDIT: almost forgot, to make these changes perminent, add them to the
file, everything in there is run when that user opens Vim, so should you discover any other nifty features or settings you like, just add them to that .
Yeah, syntax highlighting works (not in the terminal, where all text is yellow, but in gvim), but I was really hoping for this feature.
Of course, now that I also have autoindenting to where the last line was, I may not even need this...
Either way, thanks a bunch.
The 'smartindent' feature will return brackets to the same level for some coding styles. See:
note that you need to compile with +smartindent, I can't be 100% certain on what gentoo does, can't be positive if it complies it in (see the ebuild here:
hope it helps ya
"set sw=4" (shiftwidth) is useful to avoid running out of screen width.
Use Ctl-D to cancel one level of indent; there's also a way to cancel the indent just for a single line, but I can't recall the command at the moment. Anyone?
And if you're writing a document, "set wm=8" (wrapmargin) will cause lines to autowrap before they hit the edge of the screen.