如果我正在從控制檯vim的(我在Linux上做的,因爲我使用ssh獨家),然後我經常用CTRL-Z暫停活力。然後做我的外殼的東西和fg返回到vim。
在vim中使用ctags
非常有用 - help tags
欲瞭解更多信息。
我使用了一個相當強大的perforce插件:http://www.vim.org/scripts/script.php?script_id=240。差異支持令人驚歎,因爲您可以循環瀏覽所有打開的文件,或查看兩個較舊版本之間的文件歷史記錄和差異。嘗試:PVDiff,:PFilelog和:POpened。
我爲諸如搜索和緩衝窗口操作之類的東西定義了很多宏。我在這裏列出了一些有趣的宏/函數,它們幫助我生活在vim中。
剪貼板:
let mapleader=","
" put from clipboard
nmap ,p "*p
" yank to clipboard
nmap ,y "*y
標籤:
" jump to tag in other window
map t :call TagJumpOtherWindow()<cr>
function! TagJumpOtherWindow()
let cw = expand("<cword>")
winc p
exec "tjump " . cw
let @/ = cw
normal z.
winc p
endfunction
劃痕:
let mapleader=","
nmap ,x0 :e e:/work/scratch0.txt<CR>
nmap ,x1 :e e:/work/scratch1.txt<CR>
nmap ,x2 :e e:/work/scratch2.txt<CR>
nmap ,x3 :e e:/work/scratch3.txt<CR>
nmap ,x4 :e e:/work/scratch4.txt<CR>
nmap ,x5 :e e:/work/scratch5.txt<CR>
nmap ,x6 :e e:/work/scratch6.txt<CR>
nmap ,x7 :e e:/work/scratch7.txt<CR>
nmap ,x8 :e e:/work/scratch8.txt<CR>
nmap ,x9 :e e:/work/scratch9.txt<CR>
IDE:
function! GetMsdevFile(line)
let mx = '^\s*\([a-zA-Z_/\.0-9:\- ]*\)'
let line = matchstr(a:line, mx)
let file = substitute(line, mx, '\1', '')
let file = substitute(line, '\\', '/', '')
return file
endfunction
function! GetMsdevLineNumber(line)
let mx = '^\s*\([a-zA-Z_/\.0-9:\- ]*\)(\(\d\+\))'
let line = matchstr(a:line, mx)
let linenumber = substitute(line, mx, '\2', '')
return linenumber
endfunction
function! GetMsdevFile2(line)
let file = expand("%:p:h") . "/" . GetMsdevFile(a:line)
let file
return file
endfunction
function! GetMsdevFile2(line)
let file = expand("%:p:h") . "/../" . GetMsdevFile(a:line)
let file
return file
endfunction
function! GotoMsdevMake(thiswin, version)
exec "cd ".$DIRECTORY."\\.."
let l = getline(".")
if a:version==0
let file = GetMsdevFile(l)
let linenumber = GetMsdevLineNumber(l)
elseif a:version==1
let file = GetMsdevFile2(l)
let linenumber = GetMsdevLineNumber(l)
else
let file = GetMsdevFile3(l)
let linenumber = GetMsdevLineNumber(l)
endif
if a:thiswin==1
winc p
endif
exec "e +" . linenumber. " " . file
exec "cd -"
endfunction
function! GetGCCFile(line)
let mx = '^\([a-zA-Z_/\.0-9:\- ]*\):[0-9]\+: .*'
let line = matchstr(a:line, mx)
let file = substitute(line, mx, '\1', '')
let file = substitute(file, '\\', '/', '')
return file
endfunction
function! GetGCCLineNumber(line)
let mx = '^\([a-zA-Z_/\.0-9:\- ]*\):\([0-9]\+\):.*'
let line = matchstr(a:line, mx)
let linenumber = substitute(line, mx, '\2', '')
return linenumber
endfunction
function! GotoGCCMake()
exec "cd ".$DIRECTORY."\\.."
let l = getline(".")
let file = GetGCCFile(l)
let linenumber = GetGCCLineNumber(l)
winc p
exec "e +" . linenumber. " " . file
exec "cd -"
endfunction
function! MakeOut(filename)
exec ":e " . a:filename
call MakeBuffer()
normal zz
endfunction
" use the current buffer into a Visual Studio build output buffer to jump to errors
function! MakeBuffer()
normal! gg
exec "/).*error\\|failed"
nnoremap <buffer> <cr> :call GotoMsdevMake(1, 0)<cr>
nnoremap <buffer> :call GotoMsdevMake(1, 1)<cr>
nnoremap <buffer> o :call GotoMsdevMake(1, 1)<cr>
" nnoremap <buffer> :call GotoMsdevMake(0, 0)<cr>
endfunction
" use the current buffer into a GCC build output buffer to jump to errors
function! MakeGCCErr()
normal! gg
exec "/: error:"
nnoremap <buffer> <cr> :call GotoGCCMake()<cr>
nnoremap <buffer> :call GotoGCCMake()<cr>
nnoremap <buffer> o :call GotoGCCMake()<cr>
endfunction
function! MakeGCCOut(filename)
exec ":e " . a:filename
call MakeGCCErr()
endfunction
nmap ,mr :call MakeOut("e:/perforce/branch/obj/release/BuildLog.htm")<cr>
nmap ,md :call MakeOut("e:/perforce/branch/obj/debug/BuildLog.htm")<cr>
nmap ,mm :call MakeBuffer()<CR>
nmap ,mq :call MakeGCCErr()<cr>
不要關閉vim ... – aqua 2012-01-15 01:42:52
打開另一個? Doe沒有幫助。 – 2012-01-15 01:43:39
如何在屏幕會話內運行vims編輯多個文件?您仍然一次編輯一個文件!在詢問插件之前,你應該真的嘗試學習緩衝區和標籤。 – 2012-01-15 01:44:01