下載下傳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-