The new version 7 of vim is out, and it has a whole pile of new features. I've been poking around a bit this morning, and there are definitely some features I'm going to be using. Let's take a look at some of them.
First of all, Kevin has built some RPMs of vim version 7 for Fedora Core 5 (No longer available). If you are running FC-5, you can simply download these RPMs and install them with “rpm -Uvh”.
Spell check: I predict I will be using this a lot. I don't have particularly bad spelling, but I do sometimes make typos and spellos, and so for e-mail I would definitely like to see some hints. I already have my e-mail treated slightly differently, so it shouldn't be an issue to have spell checking on. I've added “set spelllang=en_us” to my .vimrc, so I can turn on spell checking by doing “:spell”. In my “.vimrc-mutt” I've added “set spell” to turn it on for mail messages.
In case you're wondering, in my .muttrc I do: set editor=“vim -u /home/jafo/.vimrc-mutt”, and my .vimrc-mutt does a “source /home/jafo/.vimrc” to pick up my usual settings. That's how I have a different vimrc for mutt.
One thing I'm going to have to change is the highlighting. It's currently pretty obnoxious. I've changed it to:
highlight SpellBad ctermfg=NONE ctermbg=NONE cterm=underline,bold highlight SpellCap ctermfg=NONE ctermbg=NONE cterm=underline,bold highlight SpellLocal ctermfg=NONE ctermbg=NONE cterm=underline,bold
Paren matching: vim7 now includes the ability to call code on any cursor movement, which has been used to implement highlighting of matching parens. Again, obnoxious coloring, but I've changed it to just bold the matching parens.
“Omni completion”: vim7 has the ability to do completion and suggestions based on the context you are in. For example, in this image I'm editing a Python file and after “string.” I typed Control-X Control-O, which brought up a list of completions (Template being the first in the list), and I scrolled down to “join”. Note that it's showing the docstring for “join” in the top of the window.
Quote blocks: the a' and a" and i' and i" can be used to select a quoted string. So, you could yank the current quoted string with ya' (including quotes) or yi' (excluding quotes). I'm not sure I'll use it, but it's a block that wasn't previously well defined and would be handy for macros.
Undo enhancements: vim now remembers all of your changes, including undos. So, you can, for example, make some changes, undo 3 of them, make some new changes, then get back to where you were before the undo. Previously, this branch of the undo was lost when you started making new changes. It also timestamps, so you can do things like “:earlier 10m” to change to how the file looked 10 minutes ago.
Insert at the end of the line: The “virtualedit=onemore” option allows you to move one space beyond the end of the line, like you are on the newline character. If you prefer to insert at the end of the line instead of add, that could be useful. I'd consider doing it because it keeps the cursor off the last character of the line.
Balloon help: You can write a custom function which will be called if the mouse cursor (in gvim) is left over some text for some period. They provide an example which bring up a balloon showing the column and line number.
Custom formatting: The “formatexpr” value can be set to a custom function for splitting long lines. I like to run “tw=75” for text, but for code it tends to do the wrong thing. I could, and probably will, write a custom function for Python that splits lines the way I want them split. For example, if I'm not inside parens, I probably will need a backslash added. If I'm in quotes, I'll want it to close the quote and start it up again on the new line. I currently do all this manually.
Disable highlighting on very long lines: The “synmaxcol” value specifies the maximum column to search for syntax on. I've run into files that had very long lines and vim got very unhappy when looking at them. I suspect this setting would have helped. The default is 3000, but I think I'll set it down to 300.
These are some of my favorite new features. I'm really liking it so far.comments powered by Disqus