我的.vimrc,贴出来给大家瞧瞧。有一些不太优雅的,或者个人色彩太强的,或者晦涩的,或者基于特定插件的部分已经被滤掉了。需要注意的是,对于gVim(Windows或者Linux/Unix),我把菜单栏和工具栏都隐藏了,不习惯的话把相关行注释即可。

"===================================================================
" Author:       Dutor@dutor.net.
" Email:        Xdutor@gmail.com
" Last Edited:  Dec 12 2009
"===================================================================

" --------------------set file encoding-------------------------
set fileencoding=utf-8 " default file encoding
set fileencodings=gbk,gb2312,gb18030,utf-8,cp936 " recognizable encoding
set formatoptions+=mM
"set autowrite      " auto saves changes when quitting and swiching buffer
set ambiwidth=double " ambicious code
set nocompatible    " use vim defaults
set wildmenu        " Turn on wild menu
set wildmode=full   " Set the completion mode to "full"
set ls=2            " allways show status line
set tabstop=4       " numbers of spaces of tab character
set shiftwidth=4    " numbers of spaces of (auto)indent
set scrolloff=1     " keep 1 lines when scrolling
set showcmd         " display incomplete commands in Last Line
" set hlsearch      " highlight searches
set incsearch       " do incremental searching
set ignorecase      " ignore case when searching
set ruler           " show the cursor position all the time
set novisualbell    " turn off visual bell
set nobackup        " do not keep a backup file
set number          " show line numbers
set title           " show title in console title bar
set ttyfast         " smoother changes
set modeline        " last lines in document sets vim mode
set modelines=3     " number lines checked for modelines
set shortmess=atI   " Abbreviate messages
"set whichwrap=b,s,h,l,<,>,[,]   " move freely between files
" informative status line, with filename&format&ValueOfChar&positon&length
set statusline=%<%F%m%r\ [%Y]\ [ASCII=\%.3b]\ [HEX=0x\%.2B]%=[POS=%l,%v]\ [LEN=%L]\ %p%%
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
" --------------------something on C/C++------------------------
set autoindent     " always set autoindenting on
set smartindent        " smart indent
set cindent            " cindent
set cino=g0         " indent class access specifier such as public, private
set expandtab      " tabs are converted to spaces, use only when required
set wrap         " don't wrap lines
set nosm             " do not show matching braces.
syntax on           " syntax highlighing
"set noautoindent
"set nosmartindent
"set nocindent
":source $HOME/.vim/abbreviation.vim
" -------------------Configuration for gVim---------------------
if has("gui_running")
    " See ~/.gvimrc
    set guifont=Courier\ New\ 12  " use this font
    set lines=30       " height = 50 lines
    set columns=100        " width = 100 columns
    set background=dark   " adapt colors for background
    set guioptions-=m       " remove the menu
    set guioptions-=T       " remove the Toolbar
    set cul                 " set CursorLine
    colorscheme darkblue    " use this color scheme
else
    colorscheme default    " use this color scheme
    "set background=dark        " adapt colors for background
endif
:hi Comment ctermfg=green
:hi StatusLine ctermbg=black
" ----------------------When Vim starts ...---------------------
":source $HOME/.vim/extern/autocmd.vim
" -----------------Keyboard mappings 閿粦瀹?--------------------
":source $HOME/.vim/extern/keybind.vim

  下面是一些键映射,仅供参考。

" escape for <ESC>
imap jj <esc>
" ' for `
map ' `
" save the file
" map <leader>w :w<cr>
map ,w :w<cr>
" quit
map ,q :q<cr>
" save and quit
map ,z ZZ
" yank from current line to the EOF
map ,yy "+yG
" paste from clipboard
map ,p "+p
" do substitution globally
map ,s :%s/
" do substitution in current line
map zs :s/
" roll up half screen
"map <tab> <C-u>
" roll down half screen
"map <space> <C-d>
" open the Calendar
map <F4> :Calendar<cr>
" open the NERDTree
map <F10> :NERDTree<cr>
" insert a \n
map ,<cr> i<cr><esc>
" Edit .vimrc
map ,,, :tabnew $HOME/.vimrc<cr>
" toggle btw. windows
map <C-H> <C-w>h
map <C-L> <C-w>l
" tabs operations
map tn :tabNext<CR>
map tp :tabprevious<CR>
map tc :tabclose<CR>
map tm :tabmove<CR>
map tf :tabfirst<CR>
map tl :tablast<CR>
"map gf :tabnew <cfile><cr>
Tags: .
你好!除了代码,此处没有多少原创之物,皆为本人搜集、整理、总结之记录与心得,欢迎转载分享!转载时请尽量注明出处,将不胜感激。祝你健康、快乐!
Home

RFC: Request For Comments. Orz..

Name(required)
Mail (required),(will not be published)

RFC: Request For Comments. Orz..

Website(recommended)