1. 基本配置: 高亮顯示查找結果: /yourword 自動補全單詞: ctrl + n,會在整個文檔中查找單詞來進行補全 語法高亮 自動縮進 tab寬度 顯示行號 等等 配置如下: set nocompatible set history=1000 set background=dark syntax on set autoindent set smartindent set tabstop=4 set shiftwidth=4 set showmatch set guioptions-=T set ruler set nohls set incsearch set nu 2. 自動排版功能: gg v G = gg(移動光標到開頭) v(打開visual模式) G(移動光標到文件尾,選中全部的) =(自動排版) 使用map命令映射ctrl+i在命令模式下進行自動排版 map <c-i> gg g G = 3. 自動補全功能括號,引號 :inoremap ( ()<ESC>i :inoremap ) <c-r>=ClosePair(')')<CR> :inoremap { {<CR>}<ESC>O :inoremap } <c-r>=ClosePair('}')<CR> :inoremap [ []<ESC>i :inoremap ] <c-r>=ClosePair(']')<CR> :inoremap " ""<ESC>i :inoremap ' ''<ESC>i function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "\<Right>" else return a:char endif endfunction 4. 在vi中執行shell命令: !command, e.g. !g++ main.cpp, !java Test.java 5. 水平拆分窗口,打開文件: vsplit xxx.c, 在窗口間移動光標: ctrl + w 6. 在buffer中打開多個文件 使用:ls列出打開的文件。:b num查看第num個文件,num是:ls中的文件序號, :b1, :b2, :bp前一個文件,:bn后一個文件 7. 打開文件瀏覽: :e . (命令是:e, .是指當前目錄, 可以指定為任意目錄, 按回打開文件或進入目錄) <F1> 顯示幫助 <cr> 如果光標下為目錄,則進入該目錄;如果光標下是文件,則用vim打開該文件 - 返回上級目錄 c 切換vim的當前工作目錄為正在瀏覽的目錄 d 創建目錄 D 刪除文件或目錄 i 切換顯示方式 R 改名文件或目錄 s 選擇排序方式 x 定制瀏覽方式,使用你指定的程序打開該文件
| 只有注冊用戶登錄后才能發表評論。 | ||
|
||
|
相關文章:
|
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|
|

