超級網迷

超級網迷+ 電腦迷+ 音樂迷
個人資料
正文

如何配置vim的.exrc文件?

(2013-11-23 13:03:14) 下一個

vim: .exrc file

I google from web to get this helpful .exrc example and the explanation:

What follows is my .exrc file for various versions of vi, and some more related stuff. I have yet to look through the vim documentation exhasutively to see if there are any more useful options — this is just stuff I have gleaned from random places on the Internet and from friends.

 

Plain vanilla vi (as on Solaris)
set nu ” show line numbers
set ts=4 ” tabs take up four columns
set sw=4 ” set shiftwidth (>> or <<) to 4 columns set showmatch ” show matches of ()’s, {}’s, and []‘s
set showmode ” show what mode (e.g. INSERT) you’re in
set autoindent ” indent to the extent of the previous line

Vim:
syntax enable ” enables syntax highlighting
set nu ” show line numbers
set ts=4 ” tabs take up four columns
set sw=4 ” set shiftwidth (>> or <<) to 4 columns
set title
” sets title of terminal in menubar to that of file currently being edited
set expandtab ” tabs aren’t really tabs, but many spaces
set softtabstop=4 ” delete four spaces when you delete a “tab”
set ignorecase ” perform case-insensitive searches…
set smartcase ” … unless there are capitalized characters in the search pattern
set mousehide ” hide the mouse when editing
set exrc ” eliminates the possibility of another .exrc getting confused with mine on multi-user systems
set backspace=indent,eol,start “explicitly makes the backspace work when at the beginning of a line
set bg=light “this almost always looks better — take this out or set it to dark if things look funny
set nohlsearch “no annoying search highlighting

” for common typos
command! Q quit
command! W write
command! Wq wq

Vim Python
set autoindent ” indent to the extent of the previous line

Vim C/C++/Java
set cindent ” indenting for C-style languages
set showmatch ” show matches of ()’s, {}’s, and []‘s

For Text (Vim 7.0 only)
setlocal spell spelllang=en_us ” English(US) spellcheck on (Vim 7.x only)
set tw=0 wrap linebreak ” don’t split words between lines, only wrap at end of word
“lots of abbreviations (varies depending on the subject material)
ab STIA Science, Technology and International Affairs

How to produce nicely formatted C code in Vim (From p.221 of href="http://www.amazon.com/Learning-Editor-6th-Arnold-Robbins/dp/1565924266/ref=pd_bbs_sr_1/102-7890135-6992916?ie=UTF8&s=books&qid=1175918735&sr=8-1">Learning the vi editor):
set nocp incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set formatoptions=tcqr
set cindent
syntax on
source ~/.exrc

Options set when vim 6.4/7 starts on my system (Ubuntu Linux):
helplang=en ” language to display help in
ruler ” show row and column in bottom right
ttyfast ” indicates a fast terminal connection
viminfo=’20,”50 ” configuration info
history=50 ” number of : commands and previous search patters to be remembered
scroll=32 ” number of lines to scroll with CRTL-U and CTRL-D commands
ttymouse=xterm2 ” mouse codes
backspace=indent,eol,start “explicitly makes the backspace work when at the beginning of a line
fileencodings=ucs-bom,utf-8,latin1 ” list of character encodings considered when starting to edit a file
printoptions=paper:letter ” controls format and output of printing
runtimepath=~/.vim,/usr/share/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vimcurrent,/usr/share/vim/vimfiles/after,/usr/share/vim/addons/after,~/.vim/after ” list of directories which will be searched for runtime files
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc ” Files with these suffixes get a lower priority when multiple files match a wildcard.

Cool stuff that I have seen various places but I didn’t find particularly useful (maybe someone else will):
set list “replaces all EOLs and TABs with $ and ^I
“auto-complete of brackets
inoremap [ []
inoremap ( ()
inoremap { {}
inoremap ” “”
inoremap ‘ ”

To see the options vi(m) has enabled, enter :set
To get help with options in Vim, enter :help set or :set all for regular vi
Or just :help for the help contents… Vim has excellent documentation 


Besides these, the ‘abbr‘, ‘map‘ sees quite powerful. For example, the following strange codes help me a lot:

abbr _href href=""
abbr _img "[image]" img src="" border="0" width="" height="" alt="[image]" align="top"
ab get_jquery script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"
ab get_bcss http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet"
ab get_bjs  "http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css"
map ,html5  charset="utf-8"
map ,body5 class="container" 


轉自William Jiang的技術博客: 鏈接

 

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.