Don't understand german? Read or subscribe to my english-only feed.

The coolest features of Vim7

  1. omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni]
  2. internal grep: vimgrep foo bar [:he vimgrep]
  3. tab pages: vim -p file1 file2 – then use the :tab command [:he tabpage]
    gt -> next tab
    gT -> previous tab
  4. undo branches: :undolist / :earlier 2h / :later 2h
    instead of using u (undo) and CTRL-R (redo), you might experiment with g- and g+ to move through the text state [:he undolist]
  5. browse (and of course edit) remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim]
  6. start editing the filename under the cursor and jump to the line number following the file name: press gF [:he gF]
  7. press ‘CTRL-W F’ to start editing the filename under the cursor in a new window and jump to the line number following the file name. [:he CTRL-W_F]
  8. spelling correction [:he spell]:
    ]s -> Move to next misspelled word after the cursor
    zg -> Add word under the cursor as a good word to the first name in ‘spellfile’
    zw -> Like “zg” but mark the word as a wrong (bad) word
    z= -> For the word under/after the cursor suggest correctly spelled words
  9. highlight active cursor line using ‘set cursorline’ [:he cursorline]
  10. delete inner quotes inside HTML-code using cit [:he tag-blocks]

Configuration template for your ~/.vimrc:

if version >= 700
" Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz
" turn spelling on by default:
"  set spell
" toggle spelling with F12 key:
map <F12> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
set spellfile=~/.vim/spellfile.add

" change language -  get spell files from http://ftp.vim.org/pub/vim/runtime/spell/
" cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.latin1.spl
" change to german:
"  set spelllang=de

" highlight matching parens:
" set matchpairs=(:),[:],{:},< :>
" let loaded_matchparen = 1
" highlight MatchParen term=reverse   ctermbg=7   guibg=cornsilk

" highlight the cursor line and column:
" set cursorline
" highlight CursorLine   term=reverse   ctermbg=7   guibg=#333333
" highlight CursorColumn guibg=#333333

" delete Inner-Quotes - very useful within HTML-code!
imap <F10> <C-O>cit

" set maximum number of suggestions listed to top 10 items
set sps=best,10
endif

Note: all of the above is brought to grml-users via /etc/skel/.vimrc of current grml-etc package and will be shipped with the next grml-release of course.

4 Responses to “The coolest features of Vim7”

  1. Julius Plenz Says:

    I also found the ‘pumheight’ option pretty handy when using vim7 over a SSH connection. If you set this option to 7, the completion menu will just dispay 7 items at a time, thus avoiding too much unnecessary terminal redraws. YMMV.

    I Omni-Completion for CSS des work fine in HTML and PHP file, in external *.css files it doesn’t, though. Does it work for you?

    Oh, and by the way: I’d call "cit" rather "cut [out] inner tag" (which is what it really does).

  2. mika Says:

    @julius:

    pumheight – nice, thanks :)

    same problem with external css-files here, even though ft=css is set, seems to be a bug

    oh and thanks for the "cit"-description as well :-)

    regards,
    -mika-

  3. Peter Stuifzand Says:

    Hi,

    great stuff! Ok, I don’t want to be picky, but I am. The c actually stands for change, so that makes it change inner tag. Also new in the same category: ci" which will remove the text between quotes and leave you in insert mode; also works for ‘ and `. If you want to change the contents of a tag like <h1> to <h2>, you can now type: ci<h2<ESC>, which will remove everything between < and > and replace it with h2.

    –Peter

  4. mika Says:

    @Peter: thanks for your comment, I updated the configuration file for vim on grml corresponding. :)

    mfg,
    -mika-