Vim is a fast and feature-rich text editor. It offers syntax highlighting for many programming and scripting languages, editing by regular expressions, and a lot more. In this post I give first a short introduction to vim then I show how to enable some of its powerful features by default on start of vim.
Introduction to Vim
Vim is free as in beer and speech and was created as an extended version of the vi editor, with many additional features designed to be helpful in editing program source code and the name Vim stands for Vi IMproved. Vim is cross-platform, which means that it works on many different operating systems, including Windows, Linux, and Mac.
Handling of Vim is not completely intuitive, however vim can make you very fast when you edit text as this screencast demonstrates.
Vim gives you great power, which comes at the price of a steep learning curve. There is a tutorial (command :vimtutor), online documentation, you can find many cheatsheets on the internet. For a more accessible interface to vim, there is Cream, a descendant of vim.
The following video offers you a first introduction to the vim editor.
Configuration (vimrc)
In this section I describe my basic configuration for vim. We want to enable some of the powerful features that Vim offers. The initial settings depend on your system. You can check them by opening the file $VIM/vimrc (on Linux this is usually /usr/share/vim/vimrc, type :echo $VIM within vim to find out where you have them).
I want searching with smart case matching, I want to use the mouse to mark text and for jumping with the cursor, and filetype plugins, I want US American spell checking for txt, tex, and HTMLs. I also want an extended status line and have some WYSIWYG with latex which means instant compiling and viewing by pressing ctrl-k.
nocompatible most important option. nocompatible prevents vim from emulating the original vi's limitations. autoindent tells vim to use the previous line's indent level to set the indent level of the new lines. smartindent lets vim make an educated guess based on the content of the previous line (works for programming code). tabstop defines how many spaces correspond to a tabulator. showmatch tells vim to show you matching opening or closing brackets when you step on a bracket with your cursor. incsearch vim will search for text as you enter it. syntax on syntax highlighting on filetype plugin indent on load filetype plugins/indent settings ignorecase case insensitive smartcase if there are capital letters, become case sensitive wildmenu vim's command line completion clipboard=unnamed Vim yanks into the system clipboard and you can paste into other applications (in linux by middle click)
Try :help options in Vim to see all available options.
The spellfile option is for adding words to your user spell dictionary (move cursor over word and press zg).
Here goes my ~/.vimrc (exported to html by gvim):
set ignorecase smartcase
set nocompatible
set incsearch
set expandtab
set shiftwidth=2
set smarttab autoindent
syntax match Tab /\t/
hi Tab gui=underline guifg=blue ctermbg=blue
set showmatch
set ru
set mouse=a
filetype indent on
set clipboard=unnamed
filetype plugin on
set wildmenu
autocmd BufNewFile,BufRead *.txt,*.tex,*.html,README set spell spelllang=en_us
syntax on
set paste
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2
:map Q <Nop>
The last line disables the ex mode.
Further Reading:
In this excellent blog post, the author gives some very useful hints, including code folding and multiple clipboards. Also, you might want to read an introduction to personalization of vim.
More great vim commands you can find at CommandLineFu.
Image Credit:
vim screenshot at wikipedia.
U COMMENT
I FOLLOW

Very good information about this Vim Editor it looks very useful,and I like everything that can give me a easy way to do it
Subscribe to replies to this post
This conversation is missing your voice. Your feedback is appreciated.
Post a Comment
You can use some HTML tags, such as <b>, <i>, <a>
You can follow the discussion of this post by subscribing.
You are free to include information from this article on your own site if you provide a backlink. You can use the following markup: