标题:Felix的vimrc (vim配置文件) 出处:Felix021 时间:Sun, 17 Aug 2008 06:10:22 +0000 作者:felix021 地址:https://www.felix021.com/blog/read.php?1092 内容: 已经移动到了我的GitHub上: https://github.com/felix021/myenv/blob/master/.vimrc === 以下请忽略 === 旧版本就不留了,一旦有最新的,我就直接覆盖了 -- @ 2010-12-22 设置dir参数,让.swp文件保存在同一个目录下(详情help directory) @ 2010-08-18 合并win和linux版本; 重新映射j/k到gj/gk,在自动换行的时候可以上下走动(而不是一次走好几行)。 @ 2010-07-19 linux版增加快捷键映射,支持(安装了CTAGS)在新tab中打开光标下的单词 @ 2010-06-08 windows版更新对python文件的基本设置 @ 2010-04-03 windows版更新 G++编译增加一个-D__DEBUG__参数,给添加的模板增加一个用于调试的宏dp,使用类似printf。 @ 2009-09-12 加入makefile的noexpandtab @ 2009-05-13 修改CPPSET等函数,在运行的时候打开另一个gnome-terminal; 改用xelatex编译tex文档 @ 2009-04-11 开启modeline, 增加set encoding,能够对付多种编码了:) @ 2009-04-02 实现的功能是,语法高亮,自动缩进(4格),显示行号,突出当前行,状态栏显示文件路径信息和光标所在行列 F3 显示当前错误 F4 跳转到第一个错误 F5 注释当前行/选中行 F6 取消注释当前行/选中行 F7 显示错误列表 F8 本来是映射到调试,但是发现没什么用,就干脆取消掉了 F9 编译(支持C/C++/Java/PHP/TeX), 对应PHP就是运行,TeX就是pdflatex编译 Ctrl+F9 运行(支持C/C++/Java/PHP/TeX), PHP就是运行,TeX就是evince打开查看 F12 插入C++模板 CTRL+T是:tabedit新建一个tab 普通模式,TAB是:tabnext,下一个tab, SHIFT+TAB是:tabprevious,上一个TAB 编辑模式下快速输入ppp,自动替换为 printf("光标位置"); 编辑模式下快速输入sss,自动替换为 scanf("光标位置"); 编辑模式下快速输入if(, while(, for(都会自动把后续的){}补全,然后光标停留在()中间 编辑模式下快速输入#inc,自动替换为 #include<[光标位置]> 在普通模式下输入 [,n] 为取消搜索高亮 [,a] 为全选 [Ctrl+C]为复制 [,p] 为粘贴 .... 更多功能自己发掘:D 以下是.vimrc的内容: if v:progname =~? "evim" finish endif set nocompatible "------------------------------ "Start of Felix's customization syntax on set modeline set fileencodings=ucs-bom,utf-8,gb18030,cp936,big5,euc-jp,sjis,euc-kr,ucs-2le,latin1 set tabstop=4 set softtabstop=4 set shiftwidth=4 set cindent set expandtab set cursorline set number set scrolloff=3 set sidescrolloff=5 set ignorecase set magic set wrap set mouse=a set hlsearch set incsearch set timeoutlen=350 if has('win32') set termencoding=cp936 set fileformat=dos set fileencoding=cp936 set dir=C:\ else set fileformat=unix set fileencoding=utf-8 set dir=/tmp endif autocmd FileType c call CPPSET() autocmd FileType c set makeprg=gcc\ -O2\ -Wall\ -Wno-unused-result\ -o\ %<.exe\ % autocmd FileType cpp call CPPSET() autocmd FileType php call PHPSET() autocmd FileType java call JAVASET() autocmd FileType python call PYSET() autocmd FileType make set noexpandtab set complete+=k func! CPPSET() set cindent set makeprg=g++\ -O2\ -Wall\ -Wno-unused-result\ -D__DEBUG__\ -o\ %<.exe\ % map :w!:make:cl map :!gdb %<.exe if has('win32') map :!start cmd /c "%<.exe && pause \|\| pause" else if has('gui') map :!gnome-terminal --command="bash -c 'time \"./%<.exe\"; read -p \" Press Enter...\"'"& else map :!time ./%<.exe endif endif endfunc func! PYSET() if has('win32') map :w!:!start cmd /c "python % && pause \|\| pause" map else map :w!:!python % map endif set expandtab endfunc func! PHPSET() map :w!:!php -l % set cindent if has('win32') map :!start cmd /c "d:/web/php/php.exe % && pause \|\| pause" else map :w!:!php % endif endfunc! func! JAVASET() set makeprg=javac\ % set cindent map :w!:make:cl "For windows, use if has('win32') map :!start cmd /c "java %< && pause \|\| pause" else map :!time java "%<"; read -p "Press Enter..."& endif endfunc "F3 for Display Current Error map :cc "F4 for First Error map :cr:cc "F5 for comment noremap :s/^\(\s*\)\(\/\/\)*/\1\/\//g:noh "F6 for remove comment noremap :s/^\(\s*\)\(\/\/\)*/\1/g:noh "F7 for Error List map :cl imap imap imap imap imap imap imap imap imap imap ppp printf(""); imap sss scanf(""); imap #inc #include <> let mapleader="," if has('win32') set gfn=Consolas:h14 map "+p imap endif noremap j gj noremap k gk " for select-all, copy, paste map a ggVG map "+y map p "+p map f T map :tabedit imap :tabedit map :tabnext map :tabprevious " ,n for no highlight search(temporary) nmap n :noh if has('win32') map :cd d:/code else map :cd ~/code endif " F12 to insert template map ggdG:call Template()/main:nohjo func! Template() call setline(1, "#include") call append(line('$'), "#include") call append(line('$'), "#include") call append(line('$'), "#include") call append(line('$'), "#include") call append(line('$'), "#include") call append(line('$'), "#include") call append(line('$'), "using namespace std;") call append(line('$'), "#ifdef __DEBUG__") call append(line('$'), "#define dp(fmt, x...) fprintf(stderr, \"[%d] \" fmt, __LINE__, ##x)") call append(line('$'), "#else") call append(line('$'), "#define dp(fmt, x...)") call append(line('$'), "#endif") call append(line('$'), "") call append(line('$'), "int main()") call append(line('$'), "{") call append(line('$'), " return 0;") call append(line('$'), "}") call append(line('$'), "") endfunc " status line set laststatus=2 set statusline=\ %F%m%r\ \ \ %{getcwd()}%h\ \ \ Line:\ %l/%L:%c "End of Felix's customization "---------------------------- set backspace=indent,eol,start set nobackup " do not keep a backup file, use versions instead set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " Don't use Ex mode, use Q for formatting map Q gq set mouse=a syntax on set hlsearch if has("autocmd") filetype plugin indent on augroup vimrcEx au! autocmd FileType text setlocal textwidth=78 autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END else set cindent endif " has("autocmd") command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis noremap vnoremap inoremap Generated by Bo-blog 2.1.0