mercredi 30 janvier 2008

VIM editor advanced tips n' tricks.

Vi IMproved is a powerful text based text editor in the UNIX world. Below are some of the most important tips I rely upon when using this text editor in my everyday work.
These tips are completely uncategorized and appear in the order I added them to this post.
  • Finding opening and closing curly brackets in a code block: [{ and ]} useful if we want to locate the beginning of a long if block.

  • Converting a pattern to uppercase. Suppose we want to convert the word "pattern" (without the double quotes) to uppercase. Here is how to do it in vim: :%s/\(pattern\)/\U\1/g

  • Auto-completion magic: pressing Ctrl+P after typing the first letter of a word will auto-complete the word in vim.

  • Basic indentation support for Java.
    In .vimrc file put the following:

    set autoindent

    set si

    set shiftwidth=4

    set smarttab

    inoremap { {<cr>}<left><cr><up><tab>

    inoremap ( ()<left>

    inoremap " ""<left>

  • useful links:
    http://www.vim.org/tips
    http://vim.wikia.com/wiki


Aucun commentaire: