nmap <C-c><C-c> :!gcc -Wall % -o %:r.exe<CR>
試用了一下覺得還不錯,唯一的缺點是錯誤訊息不會輸出到QuickFix視窗。所以我稍微的給他改了一下,如下,將以下寫入_vimrc,以後編譯改成輸入:make,即會用gcc編譯,且訊息會導至QuickFix視窗。
set mp=gcc\ -Wall\ %\ -o\ %:r.exe
nmap <C-c><C-c> :!gcc -Wall % -o %:r.exe<CR>
set mp=gcc\ -Wall\ %\ -o\ %:r.exe
map sa :exec "/\\(".getreg('/')."\\)\\\\|".expand("<cword>")<CR>
map fh <esc>:call FileHeaderSource()<cr>
function! FileHeaderSource()
let fextname=expand("%:e")
let fname=expand("%:r")
if fextname=="h"
if filereadable(fname.".cpp")
exec ':e '.fname.".cpp"
return
endif
if filereadable(fname.".c")
exec ':e '.fname.".c"
return
endif
else
if filereadable(fname.".h")
exec ':e '.fname.".h"
return
endif
endif
echo "file not found"
endfunction
:if &term == "xterm"
: " Do stuff for xterm
:elseif &term == "vt100"
: " Do stuff for a vt100 terminal
:else
: " Do something for other terminals
:endif
a == b equal to
a != b not equal to
a > b greater than
a >= b greater than or equal to
a < b less than
a <= b less than or equal to
:if 0 == "one"
: echo "yes"
:endif
a =~ b matches with
a !~ b does not match with
:if str =~ " "
: echo "str contains a space"
:endif
:if str !~ '\.$'
: echo "str does not end in a full stop"
:endif
:while counter < 40
: call do_something()
: if skip_flag
: continue
: endif
: if finished_flag
: break
: endif
: sleep 50m
:endwhile
:try
: read ~/templates/pascal.tmpl
:catch /E484:/
: echo "Sorry, the Pascal template file cannot be found."
:endtry
:let tmp = tempname()
:try
: exe ".,$write " . tmp
: exe "!filter " . tmp
: .,$delete
: exe "$read " . tmp
:finally
: call delete(tmp)
:endtry
map rfa <ESC>:call Foo()<CR>
function! Foo()
echo "Hello world 1"
endfunction
:source $VIM\_vimrc
:echo 0x7f 036
127 30
:echo 0x7f - 036
97
\t <Tab>
\n <NL>, line break
\r <CR>, <Enter>
\e <Esc>
\b <BS>, backspace
\" "
\\ \, backslash
\<Esc> <Esc>
\<C-W> CTRL-W
b:name variable local to a buffer
w:name variable local to a window
g:name global variable (also in a function)
v:name variable predefined by Vim
$NAME environment variable
&name option
@r register (list all by :reg)
let
unlet
exists("s:call_count")
:if !exists("s:call_count")
: let s:call_count = 0
:endif
:echo "called" s:call_count "times"
:if "true"
a + b add
a - b subtract
a * b multiply
a / b divide
a % b modulo
:echo "foo" . "bar"
foobar
:execute "normal " . normal_commands
:let optname = "path"
:let optval = eval('&' . optname)
:exe 'let optval = &' . optname
*a.txt*
|b.txt|
------------------------------------------------------------------------------
vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
*b.txt*
|a.txt|
vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
:g/Rickey is foolish/d
let g:template['c']['main'] = "int main(int argc, char \*argv\[\])\<cr>{\<cr>".g:rs."...".g:re."\<cr>}"
let g:Tb_MaxSize = 2
let g:Tb_TabWrap = 1
[問題]vim如何作到ultraedit的自動插入數字列號
input int[0]
input int[1]
input int[2]
input int[3]
如上面的sample code
在ultraedit裡面, 可以用 "區塊-->插入數字列號" 來自動插入一整排的等差數列
如上面的 0 -3, 請問在vim裡面要如何辨到? 謝謝
qa
yy
p
Ctrl-a
q
:0put =range(11,15)
11
12
13
14
15
:for i in range(0,3) | put ='input int['.i.']' | endfor
<leader>vv- Grep for the word under the cursor
<leader>va - Like vv, but add to existing list
<leader>vo - Select the files to search in and set grep options
:Grep SearchString
map f/ <esc>:Grep
let g:EasyGrepCommand = 1
let g:EasyGrepFileAssociations = "C:\\Program Files\\Vim\\vim72\\plugin\\EasyGrepFileAssociations"
let g:EasyGrepRecursive = 1
let g:EasyGrepHidden = 0
let g:EasyGrepExtraWarnings=0
let g:EasyGrepIgnoreCase= 1
:set ic
:set ic
:%s/AAA/&123/cg
an 50.20 &View.File\ Viewer<Tab><F5> <ESC>:NERDTreeToggle<CR>
map <F5> <ESC>:NERDTreeToggle<CR> " Toggles NERD Tree view (file viewer)
" ----------------------------
" 基本操作
o: 開檔/資料匣/書籤
x: 關資料匣
O: 開資料匣包含子資料匣
X: 關資料匣包含子資料匣
D: 刪除書籤
" ----------------------------
" 巡訪樹快速鍵
P: 到根目錄
p: 到母節點
K: 到第一個兄節點
J: 到最後一個兄節點
Ctrl+j: 到下一個兄節點
Ctrl+k: 到上個兄節點
" ----------------------------
" 檔案系統
C: 改變根目錄至所選資料匣
u: 改變根目錄至上一層的根目錄
U: 改變根目錄至上一層的根目錄且原來的目錄開著
cd: 改變工作目錄到現在所選目錄
" ----------------------------
" 書籤指令
:Bookmark <name>
:BookmarkToRoot <name>
:RevealBookmark <name>
:OpenBookmark <name>
:ClearBookmarks [<name>]
:ClearAllBookmarks
map <silent> <C-\> :FuzzyFinderTag! <C-r>=expand('<cword>')<CR><CR>
:FuzzyFinderBuffer " launchs Fuzzyfinder as Buffer mode.
:FuzzyFinderFile " launchs Fuzzyfinder as File mode.
:FuzzyFinderDir " launchs Fuzzyfinder as Directory mode.
:FuzzyFinderMruFile " launchs Fuzzyfinder as MRU-File mode.
:FuzzyFinderMruCmd " launchs Fuzzyfinder as MRU-Command mode.
:FuzzyFinderBookmark " launchs Fuzzyfinder as Bookmark mode.
:FuzzyFinderTag " launchs Fuzzyfinder as Tag mode.
:FuzzyFinderTaggedFile " launchs Fuzzyfinder as Tagged-File mode.
<cr> - opens in a previous window.
<c-j> - opens in a split window.
<c-k> - opens in a vertical-split window.
<c-]> - opens in a new tab page.
<c-l> or <c-o> " To Switch the mode without leaving Insert mode.
<c-t> " If you want to temporarily change whether or not to ignore case
<c-e> " 暫時關閉pop視窗
<c-x><c-u> " 重新打開pop視窗
:FuzzyFinderRemoveCache " 刪除Cache資料
map ff <esc>:FuzzyFinderFile<cr>
map fcd <esc>:FuzzyFinderDir<cr>
map fba <esc>:FuzzyFinderAddBookmark<cr>
map fbl <esc>:FuzzyFinderBookmark<cr>
map fu <esc>:FuzzyFinderBuffer<cr>
map <silent> <c-\> :FuzzyFinderTag! <c-r>=expand('<cword>')<cr><cr>
map <c-f12> <esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
an 40.310.10 &Tools.F&uzzyFinder.&File<tab>ff <esc>:FuzzyFinderFile<cr>
an 40.310.10 &Tools.F&uzzyFinder.Tag&File <esc>:FuzzyFinderTaggedFile<cr>
an 40.310.20 &Tools.F&uzzyFinder.&Dir<tab>fcd <esc>:FuzzyFinderDir<cr>
an 40.310.30 &Tools.F&uzzyFinder.&Bookmark<tab>fbl <esc>:FuzzyFinderBookmark<cr>
an 40.310.40 &Tools.F&uzzyFinder.&BookmarkAdd<tab>fba <esc>:FuzzyFinderAddBookmark<cr>
an 40.310.50 &Tools.F&uzzyFinder.B&uffer<tab>fu <esc>:FuzzyFinderBuffer<cr>
an 40.310.60 &Tools.F&uzzyFinder.&Tag <esc>:FuzzyFinderTag<cr>
an 40.310.70 &Tools.F&uzzyFinder.MRU-&File <esc>:FuzzyFinderMruFile<cr>
an 40.310.80 &Tools.F&uzzyFinder.MRU-&Command <esc>:FuzzyFinderMruCmd<cr>
an 40.310.90 &Tools.F&uzzyFinder.-SEP1- <nop>
an 40.310.100 &Tools.F&uzzyFinder.ClearCache <esc>:FuzzyFinderRemoveCache<cr>
:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f "%:p:h\\tags" "%:p:h"
Ctrl+] " 根據游標所在位置的字串常做關鍵字,跳進去(快速鍵:tj)。
Ctrl+t " 跳出來。
:tselect " 當有多個關鍵字在tags file中被找到時,可用tselect來選。
:tags " 查看現跳到那裡了快速鍵:ta)。
:tnext " 跳到下一個被找到的tag(快速鍵:tn)。
:tprev "跳到前一個被找到的tag(快速鍵:tp)。
cscope -Rbkq
find . -name "*.h" -o -name "*.c" -o -name "*.cc" > cscope.files
cscope -Rbkq cscope.files
Ctrl+\ s "s表Symbol,列出所有參考到游標所在字串的地方,包含定義和呼叫。
ctrl+\ g "g表Global,與ctags的Ctrl+]相同。
ctrl+\ c "c表Call,列出所有以游標所在字串當函數名的地方。
ctrl+\ t "t表Text,列出專案中所有出現游標所在字串的地方。
ctrl+\ f "f表File,以游標所在字串當檔名,開啟之。
ctrl+\ i "i表Include,以游標所在字串當檔名,列出所有include此檔的檔案。
ctrl+\ d "d表calleD,以游標所在字串當函式名,列出所有此函式呼叫的函式。
map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f "%:p:h\\tags" "%:p:h"
map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
map :!cscope -Rbkq
nmap :exec "tjump ".expand("")
nmap :exec "ts ".expand("")<>CR>
nmap :exec "tnext"
nmap :exec "tprevious"
map :SrcExplToggle
map <F6> <ESC>:TlistToggle<CR>
let Tlist_Show_One_File = 1 " Displaying tags for only one file~
let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
let Tlist_Use_Right_Window = 0 " split to the right side of the screen
let Tlist_Sort_Type = "order" " sort by order or name
let Tlist_Display_Prototype = 0 " do not show prototypes and not tags in the taglist window.
let Tlist_Compart_Format = 1 " Remove extra information and blank lines from the taglist window.
let Tlist_GainFocus_On_ToggleOpen = 0 " Jump to taglist window on open.
let Tlist_Display_Tag_Scope = 1 " Show tag scope next to the tag name.
let Tlist_Close_On_Select = 0 " Close the taglist window when a file or tag is selected.
let Tlist_Enable_Fold_Column = 0 " Don't Show the fold indicator column in the taglist window.
let Tlist_WinWidth = 40
:make a
:make " 編譯程式
:copen " 打開QF視窗
:cclose " 關閉QF視窗
:cnext " 移到下一個錯誤
:cprev " 移到前一個錯誤
:cnewer " 若有多個QF buffer,移到下一個錯誤訊息列表
:colde " 若有多個QF buffer,移到前一個錯誤訊息列表
map <F8> <ESC>:call QFSwitch()<CR>
function! QFSwitch()
redir => ls_output
execute ':silent! ls'
redir END
let exists = match(ls_output, "[Quickfix List")
if exists == -1
execute ':copen'
else
execute ':cclose'
endif
endfunction
map <F8> <ESC>:QFSwitch<CR>
map <S-F8> <ESC>:colder<CR>
map <C-F8> <ESC>:cnewer<CR>
map <C-n> <ESC>:cnext<CR>
map <C-p> <ESC>:cprev<CR>
:% ! sort
:% ! cat -n
:r ! ls
:exec ":r ! cat -n ".expand("%")
:set foldmethod=syntax
:set fdm=syntax
set foldnestmax=3
zi "啟用/關閉折疊
zo "打開折疊
zc "關閉折疊
zO "打開所有折疊
zC "關閉所有折疊
zx "更新折壘,即除了游標所在折疊不關,其他都關掉
m{a-zA-Z}
`{a-zA-Z}
:marks
"<F9> mark: in plugin filesmap
<F9> <Plug>Vm_toggle_signmap
<c-F9> <Plug>Vm_goto_next_signmap
<s-F9> <Plug>Vm_goto_prev_sign
h "左
j "下
k "左
l "右
"這類移到我多到在選擇單字時
w "移動到下一個單字字首
W "移動到下一個單字字首,移動更多(某些標點符號不停)
e "移動到下一個單字字尾
E "移動到下一個單字字尾,移動更多(某些標點符號不停)
H "移到螢幕首
M "移到螢幕中
L "移到螢幕尾
zz "將目前所在行移到螢幕中
zt "將目前所在行移到螢幕第一行
zb "將目前所在行移到螢幕最後一行
* "往前找出游標所在字串 (按 n、N 繼續找)
# "往後找出游標所在字串 (按 n、N 繼續找)
gd "將游標所在字串視為 local 變數,找到定義此 local 變數的地方 (如果有的話)
% "找披配的括號
[[ "找函數的開頭
]] "找下一個函數的開頭
autocmd! BufEnter * nested call Test()
func! Test()
if bufname("%") == "-TabBar-"
wincmd j ; 跳到下面的視窗
endif
endfunction
map <C-F4> <ESC>:call CloseTab()<CR>
func! CloseTab()
let s:buf_nr = bufnr("%")
echo s:buf_nr
exec ":Tbbp "
exec ":bdelete ".s:buf_nr
endfunction
let g:Tb_MaxSize = 2
let g:Tb_TabWrap = 1
:an 10.320 &File.Open\ Tab\.\.\.<TAB>:tabnew :browse tabnew<CR>
:an 10.400 &File.-SEP2-
:%s/\t/ /cgi
:set expandtab
:retab!
:set tabstop=2