#分享 編輯器之神vim設定檔分享

#設定按f5一鍵編譯執行c/c++/python/java 不然每次都要自己在終端打一大串 map <F5> :call CompileAndRun()<CR> func! CompileAndRun() exec "w" if &filetype == 'c' exec "!clang -std=c11 % -o /tmp/a.out && /tmp/a.out" elseif &filetype == 'cpp' exec "!clang++ -std=c++11 % -o /tmp/a.out && /tmp/a.out" elseif &filetype == 'java' exec "!javac %" exec "!java %<" elseif &filetype == 'sh' :!% elseif &filetype == 'python' exec "!python3 %" endif endfunc #設定按下各種左括號會自動配對出右邊 inoremap ( ()<ESC>i inoremap [ []<ESC>i inoremap { {}<ESC>i inoremap < <><ESC>i inoremap ‘ ‘‘<ESC>i inoremap " ""<ESC>i #設定按下lh(line head)到行首 le(line end到行末 個人覺得這樣比較好記 nmap lh ^ nmap le $ #設定按下ii回到一般模式(不過這個設定會讓打i的時候反應變慢 不建議使用 map! ii <Esc> " map ii to Esc #一些介面的設定 set noswapfile syntax on set background=dark set t_Co=256 filetype on filetype indent on filetype plugin on set tabstop=4 softtabstop=4 shiftwidth=4 set scrolloff=10 set showmode set clipboard=unnamed set hlsearch set ignorecase set incsearch set splitbelow set splitright set ai set nowrap set number set cursorline set showmatch set nocompatible 另外也可以用map把hjkl移到打電動習慣wasd不過會少了用a進插入模式的功能 而且hjkl也算是vim的精髓啦(當然用得習慣讓自己工作效率高更重要
愛心
12
14
全部留言