advanced gvim

djberg96 on 2002-08-22T13:07:01

In the last week, I've learned a few more gvim commands to make me more productive. There are so many damned commands, I wonder if anyone actually knows all of them.

Anyway, the new ones I learned were the ">" and "<" keys to indent or unindent a block of highlighted code. I also learned that you can do code folding and unfolding with zf and zo, respectively. Not the prettiest, but cool.


Indenting in Vim

Dom2 on 2002-08-23T14:21:57

I kind of like Vim's indenting, although I also find it useful to use perltidy as a pipe, to really clean things up properly.

Useful commands:

  • =} - Indent to next blank line.
  • =aB - Indent this "block".
  • ^T - (insert mode) Move to next indent.
  • ^D - (insert mode) Move to previous indent.
  • !}perltidy -q - Filter paragraph through perltidy.
  • !aBperltidy -q - Filter block through perltidy.

Actually, the commands beginning with '=' there are only in Vim 6.1 and higher. I have this in my ~/.vimrc to enable them:

" Attempt to load indenting rules if possible.
if v:version >= 601
filetype indent on
endif

This provides about 99% of my needs.

-Dom

Re:Indenting in Vim

petdance on 2002-08-23T15:14:04

Also, for those using vim, not gvim, shift-V starts a line block, and ctrl-V does a column block. I use it constantly.

I also like to justify my (non-code) text fairly often, so I do plenty of :!fmt on those blocks.

Re:Indenting in Vim

Dom2 on 2002-08-23T15:29:48

I tend to use gqap rather than fmt these days. fmt is a little inflexible...

Of course, if I were a real fanatic, I'd be using DCONWAY's Text::AutoFormat.

-Dom

Re:Indenting in Vim

petdance on 2002-08-23T15:47:26

I tend to use gqap rather than fmt these days. fmt is a little inflexible...

I didn't know about :gqap. Thanks for the pointer.

Of course, if I were a real fanatic, I'd be using DCONWAY's Text::AutoFormat.

Don't think I didn't consider it... :-)