The Answer to Life, the Universe, and Everything

Thursday, August 17, 2006

Vim setting for .vimrc

Vim is the very powerful text editor for GNU/Linux. Here is the sample of the .vimrc which confortably set up your vim.
" .vimrc
" Clear any existing autocommands:
autocmd!

" *** User Interface
" use indents of 4 spaces, and have them copied down lines:
set shiftwidth=4
set tabstop=4
set shiftround
set expandtab
set autoindent

" Set for visible tab
"set listchars=tab:>-,extends:<,trail:-,eol:<
set listchars=tab:>-
set list

" The format of status line
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P

" No beep
" set vb t_vb=
set visualbell

" No auto NL
set formatoptions=q

" Show line number
set number

" have syntax highlighting in terminals which can display colours:
if has('syntax') &amp;amp;amp;amp;& (&t_Co > 2)
syntax on
endif

" have fifty lines of command-line (etc) history:
set history=50

" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd

" have the mouse enabled all the time:
set mouse=a

" don't have files trying to override this .vimrc:
set nomodeline

" Set the type of background color
set background=dark

" *** Text Formatting -- Specific File Formats
" enable filetype detection:
filetype on

" for C-like programming, have automatic indentation:
autocmd FileType c,cpp,slang set cindent

" for actual Java C (not C++) programming where comments have explicit end
" characters, if starting a new line in the middle of a comment automatically
" insert the comment leader characters:
autocmd FileType c,java set formatoptions+=ro smartindent noexpandtab tabstop=4

" for Perl programming, have things in braces indenting themselves:
autocmd FileType perl set smartindent

" for CSS, also have things in braces indented:
autocmd FileType css set smartindent

" for HTML, generally format text, but if a long line has been created leave it
" alone when editing:
autocmd FileType html set formatoptions+=tl

" for both CSS and HTML, use genuine tab characters for indentation, to make
" files a few bytes smaller:
autocmd FileType html,css set noexpandtab tabstop=4

" in makefiles, don't expand tabs to spaces, since actual tab characters are
" needed, and have indentation at 4 chars to be sure that all indents are tabs
" (despite the mappings later):
autocmd FileType make set noexpandtab shiftwidth=4

" *** Search & Replace
" make searches case-insensitive, unless they contain upper-case letters:
set ignorecase
set smartcase
set hlsearch

" show the `best match so far' as search strings are typed:
set incsearch

1 comment:

Anonymous said...

Good dispatch and this mail helped me alot in my college assignement. Thanks you for your information.