下载gvim72.exe 并安装,默认的目录在C:\Program Files\Vim\ 其中C:\Program Files\Vim\vimfiles\ 目录就相当于linux中的家目录的.vim/目录,插件,配色方案什么的的直接放里面.
下载ctags58.zip (ctags)连接Ctags
解压缩后ctags.exe到 C:\windows\system32\ .只要是放在环境变量(%path%)目录中都可以.
下载taglist,把文件分别放置到:
1. plugin/taglist.vim – taglist插件
2. doc/taglist.txt - taglist帮助文件 .
顺便贴下自己的.vimrc文件
"plugin
"{
"require Exuberant ctags for the taglist.vim sudo apt-get install exuberant-ctags
"taglist :Source code browser (supports C/C++, java, perl, python, tcl, sql,php, etc)
"http://www.vim.org/scripts/script.php?script_id=273
"TxtBrowser : Browse plain text easily (show the title tag and syntax highlight)
"http://www.vim.org/scripts/script.php?script_id=2899
"sippmate
"http://www.vim.org/scripts/script.php?script_id=2540
"The NERD tree : A tree explorer plugin for navigating the filesystem
"http://www.vim.org/scripts/script.php?script_id=1658
"Supertab aims to provide tab completion to satisfy all your insert completion needs
":SuperTabHelp command which opens a temporary buffer listing all the available types and the ability to easily switch to that type.
"MRU : Most recently used files in your file menu
"http://www.vim.org/scripts/script.php?script_id=194
"python.vim : for adjust the indent performance for python file
"http://www.vim.org/scripts/script.php?script_id=974
"}
"sudo apt-get install vim-gnome
"make you can use the system clipboard "+p { the selection content "*p }
"""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""".
"The search options affect
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5
set hls
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
"set lazyredraw
command! -nargs=1 Silent
\ | execute ':silent !'.<q-args>
\ | execute ':redraw!'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"The simple look like
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nu "set number
syntax on
set background=dark
"set cursorline
"set cursorcolumn " highlight the current column
set mouse=a " Enable mouse usage (all modes)
set scrolloff=3 "始终保持光标上下有至少3行
set scrolljump=5 "lines to scroll when cursor leaves screen
"command line set
"{
set laststatus=2 " always show the status line
set wildmenu
set wildmode=list:longest,full
" ignore these list file extensions
set wildignore=*.dll,*.o,*.obj,*.exe,*.pyc,\*.jpg,*.gif,*.png,*.pdf
"设置状态行,使其能额外显示文件的编码信息
"set statusline=\ %F\ [buffer:%n]\ \ %m%<%r\ \ \ \ %10l/%L:%c\->%p%%\ \ [%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ \ \ [%{&ff}/%Y]%=\ PWD:%{CurDir()}
set statusline=\ %F\ %m%<%r\ \ %10l/%L:%c\->%p%%\ \ [%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ \ \ [%{&ff}/%Y]%=\ PWD:%{CurDir()}
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
"}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"the map leader shortcut and the keymap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ","
let g:mapleader = ","
noremap <space> :
noremap <leader>= gg=G
inoremap <leader>w <ESC>:w<CR>
inoremap <leader>q <ESC>:q<CR>
noremap <leader>w :w<CR>
noremap <leader>q :q<CR>
noremap <leader>! :w !sudo tee % >/dev/null<CR>
noremap <leader>b :set wrap!<CR>
noremap <leader>8 :set fileencoding=utf-8<cr>:w<cr>
noremap <leader>r :! ./% <CR>
noremap <leader>e :MRU<CR>
noremap <leader>l :set nohls!<CR>
noremap <leader>h :hide<CR>
noremap <leader>n :NERDTreeToggle<CR>
noremap <leader>t :TlistToggle<CR>
noremap <leader>m :mksession! Session.vim
noremap = <c-w>10+
noremap - <c-w>10-
noremap <leader>> <c-w>10>
noremap <leader>< <c-w>10<
noremap <C-n> gt
noremap <C-p> gT
noremap tc :tabclose<CR>
noremap tn :tabedit
noremap tm :tabmove<CR>
inoremap jj <ESC>:w<CR>
cnoremap jj <ESC>
"tab键缩进
nmap <tab> V>
nmap <S-tab> V<
vmap <tab> >gv
vmap <S-tab> <gv
"move the cursor between the windows
"多个窗口的切换
set wmw=12 " set the min width of a window to 0 so we can maximize others
set wmh=1 " set the min height of a window to 0 so we can maximize others
" --- move around splits {
" move to and maximize the below split
nnoremap <C-j> <C-W>j<C-W>8+
" move to and maximize the above split
nnoremap <C-k> <C-W>k<C-W>8+
" move to and maximize the left split
"nmap <c-h> <c-w>h<c-w><bar>
nnoremap <c-h> <c-w>h<c-w>8>
" move to and maximize the right split
nnoremap <c-l> <c-w>l<c-w>8>
"nmap <c-l> <c-w>l<c-w><bar>
"nnoremap <C-j> :wincmd j<CR>
"nnoremap <C-k> :wincmd k<CR>
"nnoremap <C-h> :wincmd h<CR>
"nnoremap <C-l> :wincmd l<CR>
" 在文件名上按gf时,在新的tab中打开
map gf :tabnew <cfile><cr>
"the shortcut for cmdline
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
cnoremap <C-F> <Right>
cnoremap <C-B> <Left>
cnoremap <C-D> <del>
cnoremap <C-H> <backspace>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文本格式和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"the plugin setup
filetype plugin on
filetype plugin indent on
set sw=4 "set softswitch to 4
set tabstop=4 "set tab to 4
set softtabstop=4
set expandtab "expand tab to 4 space
set virtualedit=onemore " allow for cursor beyond last character
set shortmess+=filmnrxoOtT " abbrev. of messages (avoids 'hit enter')
"set text
set autoindent
set smartindent
"set cindent " C/C++风格缩进
set nowrap " Set no auto newline
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
"set linebreak "设置是否自动断行
set smarttab " 只在行和段开始处使用制表符,其他位置扩展成空格
set backspace=2 " 使回格键(backspace)正常处理indent, eol, start等
set nocompatible
set history=1000
set viminfo+=! " make sure it can save viminfo 确保命令历史被记录在viminfo文件中.
set autoread " Set to auto read when a file is changed from the outside
set autowrite " Automatically save before commands like :next and :make
set autochdir "Auto change the global dir of the current windows
" 设置字符集编码,默认使用utf8
if (has("win32") || has("win64") || has("win32unix"))
let g:isWin = 1
else
let g:isWin = 0
endif
if (g:isWin)
set encoding=utf-8
set termencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,gb2312
set langmenu=zh_CN.utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_cn.utf-8
set swapfile
set backup " backups are nice ...
set background=dark
"set guifont=Courier_New:h10:cANSI "英文字体 字符集可以省略不写
set guifont=Lucida_Sans_Typewriter:h10.5w6.3:cANSI "英文字体 字符集可以省略不写.空格用_代替,h字高,w字宽.float型
set guifontwide="幼圆:h11w2:cGB2312" "中文字体,字体大小,字符集
else
"the backup file and swap file in the specified directory
"{
set swapfile
set backup " backups are nice ...
set backupdir=$HOME/.vimbackup// " but not when they clog .
set directory=$HOME/.vimswap// " Same for swap files
"Creating directories if they don't exist
silent execute '!mkdir -p $HOME/.vimbackup'
silent execute '!mkdir -p $HOME/.vimswap'
set encoding=utf8
set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1
endif
"新文件编码
set fileencoding=utf-8
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
if has("gui_running")
let g:isGUI = 1
set guioptions=
set guitablabel=%N:\ %f "tab栏显示的格式:位置:文件名
set t_Co=256
set background=dark
set linespace=5 "row space.
set linespace=3 "row space.(两行的间距, 只对gvim有效.)
"Ctrl+S实现保存,如果未命名文件名会提示你选择保存路径和文件名
map <silent> <C-S> :if expand("%") == ""<CR>:browse confirm w<CR>:else<CR>:confirm w<CR>:endif<CR>
noremap <M-1> 1gt
noremap <M-2> 2gt
noremap <M-3> 3gt
noremap <M-4> 4gt
noremap <M-5> 5gt
noremap <M-6> 6gt
noremap <M-7> 7gt
noremap <M-8> 8gt
noremap <M-9> 9gt
else
let g:isGUI = 0
endif
if (g:isGUI)
set cursorline
"set guifont=DejaVu\ Sans\ Mono:11
"set guifontwide=文泉驿等宽微米黑:11
hi StatusLine guifg=yellow gui=reverse,bold guibg=black
hi StatusLineNC guifg=lightgray gui=reverse,bold guibg=black
"hi Normal guifg=#d0d0d0 guibg=#202020 gui=NONE
endif
" Really useful!
" In visual mode when you press * or # to search for the current selection
"{
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **,://
autocmd FileType c,cpp,java,perl,sh set foldmethod=indent formatoptions=croql cindent comments=sr:,://
"highlight characters after column 80.
autocmd FileType c,cpp :match ErrorMsg /\%>80v.\+/ noremap <leader>r :! ./%< <CR>
set makeprg=gcc\ -Wall\ %\ -o\ %<
" 下述代码在windows下使用会报错需要去掉./这两个字符
" C的编译和运行,编译失败还是会运行,需改进
"{
noremap <leader>c :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc -Wall % -o %<"
"exec "! ./%<"
endfunc
" C++的编译和运行
map <F6> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc
"}
"你的工作目录下有Makefile文件, 只需输入:make命令就可以进行编译了;
"没有Makefile文件,make的时候会调用 'makeprg'里参数进行编译.
"在quickfix模式里经常用到的命令有:
" :cn 跳到下一个错误 ( :help :cn )
" :cp 跳到上一个错误 ( :help :cp )
" :cl 列出所有错误 ( :help :cl )
" :cw 如果有错误列表, 则打开quickfix窗口 ( :help :cw )
" :col 到前一个旧的错误列表 ( :help :col )
" :cnew 到后一个较新的错误列表 ( :help :cnew )
set cscopequickfix=s-,c-,d-,i-,t-,e-