一大堆vimrc
时间:2007-07-22 来源:ThomasLiu83
基本的缩进和语言加亮
set syntax=on
set cinoptions+={2,0,p0,t0
set nobackup
set cindent
set syntax=cpp
set formatoptions=tcqr
自定义文件头
function Mytitle()
call setline(1,"/**********************************************")
call append(line("."),"作者:自己名字")
call append(line(".")+1,"时间:".strftime("%c"))
call append(line(".")+2,"文件名:".expand("%"))
call append(line(".")+3,"描述:")
call append(line(".")+4,"**********************************************/")
endf
map <home> <Esc>:call Mytitle()<CR><Esc>:$<Esc>o "<home>键可改为你喜欢的
按键
K&R式代码格式化
map <F5> <Esc>:1,$g/^$/d<CR><Esc>gg=G<Esc>gg "<f5>键可改为你喜欢的按键
增加注解
map <F2> <Esc><S-$>a<TAB>/**/<Esc>2ha
XP 的
set nobackup
set noswapfile
set helplang=Cn
set autoindent
set cindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set foldenable
set fdm=marker
nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf
Debian 下的 vim 的默认配置是出了名的差,所以就需要多设置几句
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set cindent
set autoindent
set showcmd
set helplang=Cn
set nofoldenable
set noswapfile
set number
set mouse=nv
set hlsearch
set incsearch
set viminfo+=h
set nocp
filetype plugin on
autocmd FileType perl set keywordprg=perldoc\ -f
nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf
syntax on
colorscheme evening
hi Normal ctermfg=grey ctermbg=black
hi Visual ctermfg=green ctermbg=black
hi Search term=reverse cterm=standout ctermfg=green ctermbg=yellow
hi IncSearch term=reverse cterm=standout ctermfg=green ctermbg=yellow
hi PmenuSel ctermbg=Green ctermfg=Yellow
根椐文件格式加注释你可以自己改一下
function Mycomment()
if &syntax=="cpp" || &syntax=="c"
execute "normal \<Esc>\<S-$>a\<TAB>/**/\<Esc>2ha"
elseif &syntax=="perl" || &syntax=="sh"
execute "normal \<Esc>\<S-$>a\<TAB>#\<Esc>k\<S-$>"
endif
endf
map <F2> <Esc>:call Mycomment()<CR><Esc>:$<Esc>o
来段很长的
" vim:shiftwidth=2:tabstop=8:expandtab
if has('autocmd')
" Remove ALL autocommands for the current group
au!
" Mark .asm files MASM-type assembly
au BufNewFile,BufReadPre *.asm let b:asmsyntax='masm'
endif
if has('gui_running')
let do_syntax_sel_menu=1
endif
if has('gui_running') && $LANG !~ '\.'
set encoding=utf-8
endif
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
set autoindent
set nobackup
set showmatch
set formatoptions+=mM
set fileencodings=ucs-bom,utf-8,gbk
set statusline=%<%f\
%h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\
%-14.(%l,%c%V%)\ %P
if has('mouse')
set mouse=a
endif
if has('multi_byte') && v:version > 601
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
endif
" Key mappings to ease browsing long lines
noremap <C-J> gj
noremap <C-K> gk
noremap <Down> gj
noremap <Up> gk
inoremap <Down> <C-O>gj
inoremap <Up> <C-O>gk
" Key mappings for quick arithmetic inside Vim
nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$
vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$
nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$
vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap
" Key mapping to stop the search highlight
nmap <silent> <F2> :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>
" Key mapping for the taglist.vim plugin
nmap <F9> :Tlist<CR>
imap <F9> <C-O>:Tlist<CR>
" Key mappings for the quickfix commands
nmap <F11> :cn<CR>
nmap <F12> :cp<CR>
" Non-GUI setting
if !has('gui_running')
" Do not increase the windows width in the taglist.vim plugin
if has('eval')
let Tlist_Inc_Winwidth=0
endif
" Set text-mode menu
if has('wildmenu')
set wildmenu
set cpoptions-=<
set wildcharm=<C-Z>
nmap <F10> :emenu <C-Z>
imap <F10> <C-O>:emenu <C-Z>
endif
endif
if has('autocmd')
function! SetFileEncodings(encodings)
let b:my_fileencodings_bak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:my_fileencodings_bak
unlet b:my_fileencodings_bak
endfunction
function! CheckFileEncoding()
if &modified && &fileencoding != ''
exec 'e! ++enc=' . &fileencoding
endif
endfunction
function! ConvertHtmlEncoding(encoding)
if a:encoding ==? 'gb2312'
return 'gbk' " GB2312 imprecisely means GBK in HTML
elseif a:encoding ==? 'iso-8859-1'
return 'latin1' " The canonical encoding name in Vim
elseif a:encoding ==? 'utf8'
return 'utf-8' " Other encoding aliases should follow here
else
return a:encoding
endif
endfunction
function! DetectHtmlEncoding()
if &filetype != 'html'
return
endif
normal m`
normal gg
if search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html;
charset=[-A-Za-z0-9_]\+">') != 0
let reg_bak=@"
normal y$
let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')
let charset=ConvertHtmlEncoding(charset)
normal ``
let @"=reg_bak
if &fileencodings == ''
let auto_encodings=',' . &encoding . ','
else
let auto_encodings=',' . &fileencodings . ','
endif
if charset !=? &fileencoding &&
\(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding
== '')
silent! exec 'e ++enc=' . charset
endif
else
normal ``
endif
endfunction
function! GnuIndent()
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal tabstop=8
endfunction
function! RemoveTrailingSpace()
if $VIM_HATE_SPACE_ERRORS != '0' &&
\(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
normal m`
silent! :%s/\s\+$//e
normal ``
endif
endfunction
" Highlight space errors in C/C++ source files (Vim tip #935)
if $VIM_HATE_SPACE_ERRORS != '0'
let c_space_errors=1
endif
" Use Canadian spelling convention in engspchk (Vim script #195)
let spchkdialect='can'
" Show syntax highlighting attributes of character under cursor (Vim
" script #383)
map <Leader>a :call SyntaxAttr()<CR>
" Automatically find scripts in the autoload directory
au FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'
" File type related autosetting
au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4
au FileType diff setlocal shiftwidth=4 tabstop=4
au FileType html setlocal autoindent indentexpr=
au FileType changelog setlocal textwidth=76
" Text file encoding autodetection
au BufReadPre *.gb call SetFileEncodings('gbk')
au BufReadPre *.big5 call SetFileEncodings('big5')
au BufReadPre *.nfo call SetFileEncodings('cp437')
au BufReadPost *.gb,*.big5,*.nfo call RestoreFileEncodings()
au BufWinEnter *.txt call CheckFileEncoding()
" Detect charset encoding in an HTML file
au BufReadPost *.htm* nested call DetectHtmlEncoding()
" Recognize standard C++ headers
au BufEnter /usr/include/c++/* setf cpp
au BufEnter /usr/include/g++-3/* setf cpp
" Setting for files following the GNU coding standard
au BufEnter /usr/* call GnuIndent()
" Remove trailing spaces for C/C++ and Vim files
au BufWritePre * call RemoveTrailingSpace()
endif
"me add
"autocmd BufNewFile *.c exec append(0,"/* */")|exec append(1,"#include
<stdio.h>") |exec append(2,"int main(void)")|exec append(3,"{")|exec
append(5," return 0;")|exec append(6,"}")| exec ':0'
autocmd BufNewFile *.c exec append(0,"#include <stdio.h>") |exec
append(1,"int main(void)")|exec append(2,"{")|exec append(4," return
0;")|exec append(5,"}")| exec ':4'
autocmd BufNewFile *.pl exec append(0,"#!/usr/bin/perl -w") | exec
append(1,"use strict;") | exec append(2,"use warnings;") | exec ':$'
"autocmd BufNewFile *.py 0r ~/.vim/skeleton/skeleton.py
map <F3> ^i#<ESC>
map <F2> ^x
set viminfo='200,\"500
set history=500
set number
再来一段长的
set nocompatible
set nobackup
set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set ai
set foldmethod=syntax "按照语法折叠代码,indent为按照缩进折叠代码,zi命令打开
/关闭所有折叠
set foldcolumn=3 "设置折叠区域的宽度
set foldclose=all "设置为自动关闭折叠
''对于安装了中文help有效
if version >= 603
set helplang=cn
endif
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source $vimruntime/colors/darkblue.vim ''设置配色方案
behave mswin
''默认配置
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if &sh =~ '\<cmd'
silent execute '!""C:\Program Files\Vim\vim64\diff" ' . opt . arg1 . '
' . arg2 . ' > ' . arg3 . '"'
else
silent execute '!C:\Program" Files\Vim\vim64\diff" ' . opt . arg1 . ' '
. arg2 . ' > ' . arg3
endif
endfunction
"设置F5为不同文件类型添加注释
filetype plugin indent on
autocmd FileType cpp,java map <F5> 0i//<Esc>
autocmd FileType c map! <F5> /* */<Esc>
autocmd FileType sh map! <F5> 0i#<Esc>
''设置F12为运行python程序,运行前需要保存
map <F12> :!c:\python24\python.exe % <CR>
注释掉一行的快捷键
function Mycomm()
let tmphehe=getline(".")
call setline(line("."),"/*")
call append(line(".")," *".tmphehe." by xx".strftime("%c"))
call append(line(".")+1," */")endf
map <F2> <Esc>:call Mycomm()<CR><ESC>
这个似乎跟编码有关
set encoding=gb2312
set cindent
set ts=4
set sw=4
set foldcolumn=2
abbreviate // // lyd[
abbreviate //m // lyd[ MARK
abbreviate //c // lyd[ CHANGED
abbreviate //a // lyd[ ADD
abbreviate //d // lyd[ DELETE
abbreviate //D // lyd[ DEBUG
abbreviate //j // lyd[ JSSUPPORT
abbreviate //t // lyd[ TODO
abbreviate printf printf ("####Benson debug:"
abbreviate printk printk ("####Benson debug:"
:map <F2> :s/^/\/\//<CR>
:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
还有一个我没见过的命令
:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
set syntax=on
set cinoptions+={2,0,p0,t0
set nobackup
set cindent
set syntax=cpp
set formatoptions=tcqr
自定义文件头
function Mytitle()
call setline(1,"/**********************************************")
call append(line("."),"作者:自己名字")
call append(line(".")+1,"时间:".strftime("%c"))
call append(line(".")+2,"文件名:".expand("%"))
call append(line(".")+3,"描述:")
call append(line(".")+4,"**********************************************/")
endf
map <home> <Esc>:call Mytitle()<CR><Esc>:$<Esc>o "<home>键可改为你喜欢的
按键
K&R式代码格式化
map <F5> <Esc>:1,$g/^$/d<CR><Esc>gg=G<Esc>gg "<f5>键可改为你喜欢的按键
增加注解
map <F2> <Esc><S-$>a<TAB>/**/<Esc>2ha
XP 的
set nobackup
set noswapfile
set helplang=Cn
set autoindent
set cindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set foldenable
set fdm=marker
nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf
Debian 下的 vim 的默认配置是出了名的差,所以就需要多设置几句
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set cindent
set autoindent
set showcmd
set helplang=Cn
set nofoldenable
set noswapfile
set number
set mouse=nv
set hlsearch
set incsearch
set viminfo+=h
set nocp
filetype plugin on
autocmd FileType perl set keywordprg=perldoc\ -f
nmap <F5> ^W_^W\|
nmap <F6> ^W=
imap <F5> <ESC>^W_^W\|a
imap <F6> <ESC>^W=a
nmap gF ^Wf
syntax on
colorscheme evening
hi Normal ctermfg=grey ctermbg=black
hi Visual ctermfg=green ctermbg=black
hi Search term=reverse cterm=standout ctermfg=green ctermbg=yellow
hi IncSearch term=reverse cterm=standout ctermfg=green ctermbg=yellow
hi PmenuSel ctermbg=Green ctermfg=Yellow
根椐文件格式加注释你可以自己改一下
function Mycomment()
if &syntax=="cpp" || &syntax=="c"
execute "normal \<Esc>\<S-$>a\<TAB>/**/\<Esc>2ha"
elseif &syntax=="perl" || &syntax=="sh"
execute "normal \<Esc>\<S-$>a\<TAB>#\<Esc>k\<S-$>"
endif
endf
map <F2> <Esc>:call Mycomment()<CR><Esc>:$<Esc>o
来段很长的
" vim:shiftwidth=2:tabstop=8:expandtab
if has('autocmd')
" Remove ALL autocommands for the current group
au!
" Mark .asm files MASM-type assembly
au BufNewFile,BufReadPre *.asm let b:asmsyntax='masm'
endif
if has('gui_running')
let do_syntax_sel_menu=1
endif
if has('gui_running') && $LANG !~ '\.'
set encoding=utf-8
endif
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
set autoindent
set nobackup
set showmatch
set formatoptions+=mM
set fileencodings=ucs-bom,utf-8,gbk
set statusline=%<%f\
%h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\
%-14.(%l,%c%V%)\ %P
if has('mouse')
set mouse=a
endif
if has('multi_byte') && v:version > 601
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
endif
" Key mappings to ease browsing long lines
noremap <C-J> gj
noremap <C-K> gk
noremap <Down> gj
noremap <Up> gk
inoremap <Down> <C-O>gj
inoremap <Up> <C-O>gk
" Key mappings for quick arithmetic inside Vim
nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$
vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$
nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$
vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap
" Key mapping to stop the search highlight
nmap <silent> <F2> :nohlsearch<CR>
imap <silent> <F2> <C-O>:nohlsearch<CR>
" Key mapping for the taglist.vim plugin
nmap <F9> :Tlist<CR>
imap <F9> <C-O>:Tlist<CR>
" Key mappings for the quickfix commands
nmap <F11> :cn<CR>
nmap <F12> :cp<CR>
" Non-GUI setting
if !has('gui_running')
" Do not increase the windows width in the taglist.vim plugin
if has('eval')
let Tlist_Inc_Winwidth=0
endif
" Set text-mode menu
if has('wildmenu')
set wildmenu
set cpoptions-=<
set wildcharm=<C-Z>
nmap <F10> :emenu <C-Z>
imap <F10> <C-O>:emenu <C-Z>
endif
endif
if has('autocmd')
function! SetFileEncodings(encodings)
let b:my_fileencodings_bak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:my_fileencodings_bak
unlet b:my_fileencodings_bak
endfunction
function! CheckFileEncoding()
if &modified && &fileencoding != ''
exec 'e! ++enc=' . &fileencoding
endif
endfunction
function! ConvertHtmlEncoding(encoding)
if a:encoding ==? 'gb2312'
return 'gbk' " GB2312 imprecisely means GBK in HTML
elseif a:encoding ==? 'iso-8859-1'
return 'latin1' " The canonical encoding name in Vim
elseif a:encoding ==? 'utf8'
return 'utf-8' " Other encoding aliases should follow here
else
return a:encoding
endif
endfunction
function! DetectHtmlEncoding()
if &filetype != 'html'
return
endif
normal m`
normal gg
if search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html;
charset=[-A-Za-z0-9_]\+">') != 0
let reg_bak=@"
normal y$
let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')
let charset=ConvertHtmlEncoding(charset)
normal ``
let @"=reg_bak
if &fileencodings == ''
let auto_encodings=',' . &encoding . ','
else
let auto_encodings=',' . &fileencodings . ','
endif
if charset !=? &fileencoding &&
\(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding
== '')
silent! exec 'e ++enc=' . charset
endif
else
normal ``
endif
endfunction
function! GnuIndent()
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal tabstop=8
endfunction
function! RemoveTrailingSpace()
if $VIM_HATE_SPACE_ERRORS != '0' &&
\(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')
normal m`
silent! :%s/\s\+$//e
normal ``
endif
endfunction
" Highlight space errors in C/C++ source files (Vim tip #935)
if $VIM_HATE_SPACE_ERRORS != '0'
let c_space_errors=1
endif
" Use Canadian spelling convention in engspchk (Vim script #195)
let spchkdialect='can'
" Show syntax highlighting attributes of character under cursor (Vim
" script #383)
map <Leader>a :call SyntaxAttr()<CR>
" Automatically find scripts in the autoload directory
au FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'
" File type related autosetting
au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4
au FileType diff setlocal shiftwidth=4 tabstop=4
au FileType html setlocal autoindent indentexpr=
au FileType changelog setlocal textwidth=76
" Text file encoding autodetection
au BufReadPre *.gb call SetFileEncodings('gbk')
au BufReadPre *.big5 call SetFileEncodings('big5')
au BufReadPre *.nfo call SetFileEncodings('cp437')
au BufReadPost *.gb,*.big5,*.nfo call RestoreFileEncodings()
au BufWinEnter *.txt call CheckFileEncoding()
" Detect charset encoding in an HTML file
au BufReadPost *.htm* nested call DetectHtmlEncoding()
" Recognize standard C++ headers
au BufEnter /usr/include/c++/* setf cpp
au BufEnter /usr/include/g++-3/* setf cpp
" Setting for files following the GNU coding standard
au BufEnter /usr/* call GnuIndent()
" Remove trailing spaces for C/C++ and Vim files
au BufWritePre * call RemoveTrailingSpace()
endif
"me add
"autocmd BufNewFile *.c exec append(0,"/* */")|exec append(1,"#include
<stdio.h>") |exec append(2,"int main(void)")|exec append(3,"{")|exec
append(5," return 0;")|exec append(6,"}")| exec ':0'
autocmd BufNewFile *.c exec append(0,"#include <stdio.h>") |exec
append(1,"int main(void)")|exec append(2,"{")|exec append(4," return
0;")|exec append(5,"}")| exec ':4'
autocmd BufNewFile *.pl exec append(0,"#!/usr/bin/perl -w") | exec
append(1,"use strict;") | exec append(2,"use warnings;") | exec ':$'
"autocmd BufNewFile *.py 0r ~/.vim/skeleton/skeleton.py
map <F3> ^i#<ESC>
map <F2> ^x
set viminfo='200,\"500
set history=500
set number
再来一段长的
set nocompatible
set nobackup
set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set ai
set foldmethod=syntax "按照语法折叠代码,indent为按照缩进折叠代码,zi命令打开
/关闭所有折叠
set foldcolumn=3 "设置折叠区域的宽度
set foldclose=all "设置为自动关闭折叠
''对于安装了中文help有效
if version >= 603
set helplang=cn
endif
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source $vimruntime/colors/darkblue.vim ''设置配色方案
behave mswin
''默认配置
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if &sh =~ '\<cmd'
silent execute '!""C:\Program Files\Vim\vim64\diff" ' . opt . arg1 . '
' . arg2 . ' > ' . arg3 . '"'
else
silent execute '!C:\Program" Files\Vim\vim64\diff" ' . opt . arg1 . ' '
. arg2 . ' > ' . arg3
endif
endfunction
"设置F5为不同文件类型添加注释
filetype plugin indent on
autocmd FileType cpp,java map <F5> 0i//<Esc>
autocmd FileType c map! <F5> /* */<Esc>
autocmd FileType sh map! <F5> 0i#<Esc>
''设置F12为运行python程序,运行前需要保存
map <F12> :!c:\python24\python.exe % <CR>
注释掉一行的快捷键
function Mycomm()
let tmphehe=getline(".")
call setline(line("."),"/*")
call append(line(".")," *".tmphehe." by xx".strftime("%c"))
call append(line(".")+1," */")endf
map <F2> <Esc>:call Mycomm()<CR><ESC>
这个似乎跟编码有关
set encoding=gb2312
set cindent
set ts=4
set sw=4
set foldcolumn=2
abbreviate // // lyd[
abbreviate //m // lyd[ MARK
abbreviate //c // lyd[ CHANGED
abbreviate //a // lyd[ ADD
abbreviate //d // lyd[ DELETE
abbreviate //D // lyd[ DEBUG
abbreviate //j // lyd[ JSSUPPORT
abbreviate //t // lyd[ TODO
abbreviate printf printf ("####Benson debug:"
abbreviate printk printk ("####Benson debug:"
:map <F2> :s/^/\/\//<CR>
:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
还有一个我没见过的命令
:inoremap( ()<ESC>i
:inoremap) <c-r>=ClosePair(')')<CR>
:inoremap{ {}<ESC>i
:inoremap} <c-r>=ClosePair('}')<CR>
:inoremap[ []<ESC>i
:inoremap] <c-r>=ClosePair(']')<CR>
function ClosePair(char)
if getline('.')[col(',') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
相关阅读 更多 +