日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

vim的强大,vim设置和插件的使用,脱离windows才是王道

發布時間:2024/8/23 windows 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vim的强大,vim设置和插件的使用,脱离windows才是王道 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> let Tlist_Show_One_File=1 let Tlist_Exit_OnlyWindow=1 let Tlist_Auto_Open=1 set nocompatible """"""""""界面"""""""""" colorscheme elflord "set guifont=Monospace\ 11 set tabstop=4 set backspace=2 set nu! "顯示行號 set nowrap set linebreak "整詞換行 set whichwrap=b,s,<,>,[,] "左右光標移動到頭時可以自動下移 "set autochdir "自動設置目錄為正在編輯的文件所在目錄 set hidden "沒有保存的緩沖區可以自動隱藏 set scrolloff=7 "設置光標上下保留的最小的行數 set smartindent "智能對齊方式 set shiftwidth=4 "換行時行間交錯使用4個空格 set autoindent "自動對齊 set ai! "設置自動縮進 set showcmd " display incomplete commands set wildmenu "增強模式的命令行 "=========狀態欄相關=========== set laststatus=2 "總是顯示狀態欄status line set ruler "在編輯過程中,右下角顯示光表位置的狀態行 set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] "==========編輯相關============ " allow backspacing over everything in insert mode set backspace=indent,eol,start " Don't use Ex mode, use Q for formatting "map Q gq " In many terminal emulators the mouse works just fine, thus enable it. if has('mouse') set mouse=v endif set autowrite "在切換buffer時自動保存當前的文件 set autoread "===========查找替換相關============ set hlsearch set incsearch "" 查詢時非常方便,如要查找book單詞,當輸入到/b時,會自動找到 " 第一個b開頭的單詞,當輸入到/bo時,會自動找到第一個bo開頭的 " 單詞,依次類推,進行查找時,使用此設置會快速找到答案,當你 " 找要匹配的單詞時,別忘記回車 set gdefault "替換所有的行內匹配都被替換,而不是第一個 "=========編程相關=========== "set completeopt=longest,menu "關掉只能補全的時的預覽窗口 filetype plugin indent on syntax on syntax enable "========================================" if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file endif " Put these in an autocmd group, so that we can delete them easily. "===================autocmd=====================" augroup vimrcEx au! "如果文件類型為text,則設置文本顯示的寬度為78,更多參考:h setlocal autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. " 如下的autocmd實現打開文件自動跳到上次編輯的位置 autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif autocmd! bufwritepost vimrc source ~/.vimrc augroup END " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif "==========自定義的鍵映射==================" "實現CTRL-S保存操作 nmap <c-s> :w<CR> imap <c-s> <Esc>:w<CR>a "實現了CTRL-C、CTRL-V復制粘貼操作的映射 vnoremap <c-c> "+y inoremap <c-v> <esc>"+p<CR>i map <F2> <c-e> "使用F2上翻頁 map <F3> <c-y> "使用F3下翻頁 map <silent> <F12> :nohlsearch<CR> let mapleader = "," let g:mapleader = "," "使用CTRL+[hjkl]在窗口間導航 "map <C-c> <C-W>c map <C-j> <C-W>j map <C-k> <C-W>k map <C-h> <C-W>h map <C-l> <C-W>l "map <C-c> <C-W>c "使用箭頭導航buffer map <right> :bn<cr> map <left> :bp<cr> " Tab configuration map <leader>tn :tabnew<cr> map <leader>te :tabedit map <leader>tc :tabclose<cr> map <leader>tm :tabmove "括號匹配 vnoremap $1 <esc>`>a)<esc>`<i(<esc> vnoremap $2 <esc>`>a]<esc>`<i[<esc> vnoremap $3 <esc>`>a}<esc>`<i{<esc> vnoremap $$ <esc>`>a"<esc>`<i"<esc> vnoremap $q <esc>`>a'<esc>`<i'<esc> vnoremap $e <esc>`>a"<esc>`<i"<esc> "非常好用的括號匹配,實際是自動生成括號 "實現便利和兼容的折中 inoremap $1 ()<esc>i inoremap $2 []<esc>i inoremap $3 {}<esc>i inoremap $4 {<esc>o}<esc>O inoremap $q ''<esc>i inoremap $e ""<esc>i inoremap $t <><esc>i "使用ALT+[jk]來移動行內容 nmap <M-j> mz:m+<cr>`z nmap <M-k> mz:m-2<cr>`z vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z "======================================== " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. inoremap <C-U> <C-G>u<C-U> "========================================" "========自動載入項目的配置文件==========" if filereadable("workplace.vim") source workplace.vim endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " cscope setting """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "自動判斷是否存在cscope并配置 if has("cscope") set csprg=/usr/local/bin/cscope set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR> " Using 'CTRL-spacebar' then a search type makes the vim window " split horizontally, with search result displayed in " the new window. "nmap <C-M>s :scs find s <C-R>=expand("<cword>")<CR><CR> "nmap <C-M>g :scs find g <C-R>=expand("<cword>")<CR><CR> "nmap <C-M>c :scs find c <C-R>=expand("<cword>")<CR><CR> "nmap <C-M>t :scs find t <C-R>=expand("<cword>")<CR><CR> "nmap <C-M>e :scs find e <C-R>=expand("<cword>")<CR><CR> "nmap <C-M>f :scs find f <C-R>=expand("<cfile>")<CR><CR> "nmap <C-M>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> "nmap <C-M>d :scs find d <C-R>=expand("<cword>")<CR><CR> " "" Hitting CTRL-space *twice* before the search type does a vertical "" split instead of a horizontal one " "nmap <C-M><C-M>s " \:vert scs find s <C-R>=expand("<cword>")<CR><CR> "nmap <C-M><C-M>g " \:vert scs find g <C-R>=expand("<cword>")<CR><CR> "nmap <C-M><C-M>c " \:vert scs find c <C-R>=expand("<cword>")<CR><CR> "nmap <C-M><C-M>t " \:vert scs find t <C-R>=expand("<cword>")<CR><CR> "nmap <C-M><C-M>e " \:vert scs find e <C-R>=expand("<cword>")<CR><CR> "nmap <C-M><C-M>i " \:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> "nmap <C-M><C-M>d " \:vert scs find d <C-R>=expand("<cword>")<CR><CR> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " end cscope setting """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""" "====== Minibuffer plugin=======" "let g:miniBufExplModSelTarget = 1 "let g:miniBufExplorerMoreThanOne = 2 "let g:miniBufExplModSelTarget = 0 "let g:miniBufExplUseSingleClick = 1 "let g:miniBufExplMapWindowNavVim = 1 "let g:miniBufExplVSplit = 25 "let g:miniBufExplSplitBelow=1 let g:bufExplorerSortBy = "name" autocmd BufRead,BufNew :call UMiniBufExplorer "使用<leader>u 打開Minibuffer map <leader>u :TMiniBufExplorer<cr> "========================================" "Auto Completion Popmenu let g:acp_behaviorSnipmateLength=1

使用插件

?

?

1安裝使用Ctags

Ctags工具是用來遍歷源代碼文件生成tags文件,這些tags文件能被編輯器或其它工具用來快速查找定位源代碼中的符號(tag/symbol),如變量名,函數名等。比如,tags文件就是Taglist和OmniCppComplete工作的基礎。

這里介紹從源代碼包安裝,安裝步驟跟大多數軟件的從源代碼安裝步驟一樣。

1)從http://ctags.sourceforge.net/下載源代碼包后,解壓縮生成源代碼目錄,

wget下載:?wgethttp://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz

tar解壓:?tar zxvf ctags-5.8.tar.gz

2)然后進入源代碼根目錄執行./configure,

3)然后執行make,

4)編譯成功后執行makeinstall。

5)在~/.vimrc中增加以下這行:

map<C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q.<CR>

到此,Ctags已安裝成功。

另外,由于在前面第5條,我們已經在Vim中配置了Ctrl-F12組合快捷鍵,所以我們也可以進入代碼根目錄后,打開Vim,按下Ctrl-F12快捷鍵自動生成tags文件。

命令執行完后,會在源代碼目錄生成tags文件。Vim默認會自動讀取當前目錄下的tags文件,所以不需要修改~/.vimrc文件。此時,我們已經具有定義跳轉的功能了。有兩組快捷鍵是最常用的。

Ctrl-]?跳轉到光標所在符號的定義。

Ctrl-t?回到上次跳轉前的位置。

更多功能通過命令manctags或在Vim命令行下運行helpctags查詢。

?

2Taglist是vim的一個插件,提供源代碼符號的結構化視圖

1)從http://www.vim.org/scripts/script.php?script_id=273下載安裝包,也可以從http://vim-taglist.sourceforge.net/index.html下載。

2)進入~/.vim目錄,將Taglist安裝包解壓,解壓后會在~/.vim目錄中生成幾個新子目錄,如?plugin和doc(安裝其它插件時,可能還會新建autoload等其它目錄)。

3)進入~/.vim/doc目錄,在Vim下運行"helptags."命令。此步驟是將doc下的幫助文檔加入到Vim的幫助主題中,這樣我們就可以通過在Vim中運行“helptaglist.txt”查看taglist幫助。

4)打開配置文件~/.vimrc,加入以下三行:

letTlist_Show_One_File=1

letTlist_Exit_OnlyWindow=1

letTlist_Auto_Open=1

?

vim實在是強大的不得了,不用不知道,一用嚇一跳,愛死了

http://blog.csdn.net/youkuxiaobin/article/details/7438774

總結

以上是生活随笔為你收集整理的vim的强大,vim设置和插件的使用,脱离windows才是王道的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。