备份一下vim的配置文件


版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息

今天写个perl的小程序的时候猛然发现自己以前设置的vim的环境还是很好用的,尽管还有点小bug,不过基本的运行和调试时没有问题了
贴出来,自己备份一下,也共享一下~~

” An example for a vimrc file.

Maintainer: Bram Moolenaar <Bram@vim.org>
” Last change: 2002 May 28

” To use it, copy it to
” for Unix and OS/2: ~/.vimrc
” for Amiga: s:.vimrc
” for MS-DOS and Win32: $VIM\_vimrc
” for OpenVMS: sys$login:.vimrc

” When started as “evim”, evim.vim will already have done these settings.
if v:progname =~? “evim”
finish
endif

” Use Vim settings, rather then Vi settings (much better!).
” This must be first, because it changes other options as a side effect.
set nocompatible

” allow backspacing over everything in insert mode
set backspace=indent,eol,start

“set autoindent ” always set autoindenting on
if has(“vms”)
set nobackup ” do not keep a backup file, use versions instead
else
set backup ” keep a backup file
endif
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

For Win32 GUI: remove ‘t’ flag from ‘guioptions’: no tearoff menu entries
” let &guioptions = substitute(&guioptions, “t”, “”, “g”)

” Don’t use Ex mode, use Q for formatting
map Q gq

“###################################################################
“@author – huangwei
“@created on – 2005-10-20
“@last modified – 10:16 2005-10-21
“——————————————————————-
” F2 – write file without confirmation
” F3 – call file explorer Ex
” F4 – show Taglist
” F5 – automatically insert current time to current location
” F8 – automatically complete keywords
” F12 – switch between windows
“——————————————————————-
map <S-Tab> :call NextField(‘ \{2,}’,2,’ ‘,0)<CR>
map! <S-Tab> <C-O>:call NextField(‘ \{2,}’,2,’ ‘,0)<CR>
” function: NextField
Args: fieldsep,minlensep,padstr,offset

” NextField checks the line above for field separators and moves the cursor on
” the current line to the next field. The default field separator is two or more
” spaces. NextField also needs the minimum length of the field separator,
” which is two in this case. If NextField is called on the first line or on a
” line that does not have any field separators above it the function echoes an
” error message and does nothing.

func! NextField(fieldsep,minlensep,padstr,offset)
let curposn = col(“.”)
let linenum = line(“.”)
let prevline = getline(linenum-1)
let curline = getline(linenum)
let nextposn = matchend(prevline,a:fieldsep,curposn-a:minlensep)+1
let padding = “”

if nextposn > strlen(prevline) || linenum == 1 || nextposn == 0
echo “last field or no fields on line above”
return
endif

echo “”

if nextposn > strlen(curline)
if &modifiable == 0
return
endif
let i = strlen(curline)
while i < nextposn - 1
let i = i + 1
let padding = padding . a:padstr
endwhile
call setline(linenum,substitute(curline,“$”,padding,“”))
endif
call cursor(linenum,nextposn+a:offset)
return
endfunc

” for quick save in normal mode
map <silent> <F2> :write<CR>
map <silent> <F3> :Explore<CR>

” switch between windows
map <silent> <F12> <C-W>w

” for quick save in edit mode
imap <F2> <ESC><F2>a

” according to SMTH’s VIM board
nnoremap <silent> <F4> :Tlist<CR>

” let F5 insert current time to current location.
map <F5> i<C-R>=strftime(“%H:%M %Y-%m-%d”)<ESC><ESC>
” map! <F5> <C-R>=strftime(“%H:%M %Y-%m-%d”)<RETURN>

“mouse function support
set mouse=a

” set auto shift width
” set shiftwidth=4

” disable auto backup
set nobackup

” set root directory of DICTIONARY, whose value by default is
” NULL to Linux
” /cygdrive/c to cygwin
C: to Win32
let g:DIC_ROOT_DIR=“C:\\dict”

” set default ‘dictionary’ path
execute “:set dictionary+=”.g:DIC_ROOT_DIR.\\words”
” more and more place including such keyword
set iskeyword+=-
” Let F8 made dictionary automatically complete keywords.
map! <F8> <C-X><C-K>

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”*
” autocmd FileType * set comments&
“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”C

autocmd FileType c call C()
fun! C()
set cindent
set comments=sr:/*,mb:*,el:*/,://
set commentstring=\ \ //\ %s\ ” <SPACE>
set foldcolumn=3
set expandtab
set tags+=/usr/include/tags
execute “:set dictionary=C:\\dict\\C”
” control-c comments block
vmap <C-C> :s/^/\/\//g<enter>
” control-x uncomments block
vmap <C-X> :s/^\/\///g<enter>
map! =for for(i = 0; i < ; i++){<LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>
endfun ” endfun C

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"CPP
autocmd FileType cpp call CPP()
fun! CPP()
set cindent
set comments=sr:/*,mb:*,el:*/,://
set commentstring=\ \ //\ %s\ ” <SPACE>
set foldcolumn=3
set expandtab
set tags+=/usr/include/tags
” control-c comments block
vmap <C-C> :s/^/\/\//g<enter>
” control-x uncomments block
vmap <C-X> :s/^\/\///g<enter>
execute “:set dictionary=C:\\dict\\CPP”
endfun ” endfun CPP

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"PERL
autocmd FileType sed,awk,perl call PERL()
fun! PERL()
set cindent
set commentstring=\ \ #\ %s\ ” <SPACE>
set foldcolumn=3
” control-c comments block
vmap <C-C> :s/^/#/g<enter>
” control-x uncomments block
vmap <C-X> :s/^#//g<enter>
” ———-22:34 2007-01-04 update this—————————–
” —–F4 查字典 F7 单步调试 F8 语法检查 F9 运行程序——-
” —–;a 自动完成—–

” —–问题:运行程序的错误和结果如何捕捉?——

“<F11> == see perldoc for current word under cursor
map <F11> :call PerlDoc(expand(“<cword>“))<CR>

“<F7> for perl debugging
map <F7> :w<CR>:!perl.exe -wd “%”<CR>
“<F8> for perl syntax checking (autosave first)
map <F8> :w<CR>:!perl.exe -wc “%”<CR>
“<F9> to run by perl (autosave first) “”,” are both ok
map <F9> :w<CR>:!perl.exe “%”<CR>

” set dictionary for perl keywords completion
set dictionary=C:\\dict\\PERL

“set autoindent depth
set shiftwidth=4
“set tabstop
set tabstop=4
“set showmatch
set showmatch

” mapping my insert commands
” I called them “;-command” ’cause you’ve the least hesitation
” between you type the “;” and the following <Space> or <CR>

“<;a> for Auto-completion using dictionary
imap ;a <C-X><C-K>
“then use <C-N> to match the next keywords, and <C-P> the previous one
” map!=imap+cmap (i=insert mode, c=:command mode)
” a) imap <Space><Space> xx also can work, but not good
” b) i cannot map <M-x> or <M-Space>, why?
” c) Ctrl-Space <=> Ctrl-@
endfun ” endfun PERL

func PerlDoc(keyword)
if a:keyword=~“::”
“module name;
exec ‘:!perldoc ‘.a:keyword
elseif a:keyword=~“^perl”
“perl pod
exec ‘:!perldoc ‘.a:keyword
else
“perl function
exec ‘:!perldoc -f ‘.a:keyword
endif
endfunc

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"HTML
autocmd FileType html call HTML()
fun! HTML()
set dictionary=C:\\dict\\JS
set dictionary+=C:\\dict\\HTML
set tabstop=4
set shiftwidth=4
endfun ” endfun HTML
“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"JAVA
autocmd FileType java call JAVA()
fun! JAVA()
set cindent
set commentstring=\ \ //\ %s\ ” <SPACE>
set foldcolumn=3
set expandtab tags+=${JAVA_HOME}/src/tags
” control-c comments block
vmap <C-C> :s/^/\/\//g<enter>
” control-x uncomments block
vmap <C-X> :s/^\/\///g<enter>
execute “:set dictionary=C:\\dict\\JAVA”
map! =for for(int i = 0; i < ; i++){<LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>
map! =psvm public static void main(String [] args){<RETURN>
map! =soutn System.out.println(
map! =sout System.out.print(
map! =try try{<RETURN>}catch(Exception e){<RETURN>System.out.println(e.getMessage());<RETURN>}<ESC>kkko
map! =tryb try{<ESC>:/^[ \t]*$/<RETURN>ddko}catch(Exception e){<RETURN>System.out.println(e.getMessage());<RETURN>}<ESC>k
endfun ” endfun JAVA

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"JSP
autocmd FileType jsp call JSP()
fun! PHP()
execute “:set dictionary=C:\\dict\\JSP”
endfun ” endfun JSP

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"JS
autocmd Filetype js call JS()
fun! JS()
set dictionary=C:\\dict\\JS
set tabstop=4
set shiftwidth=4
endfun ” endfun JS

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"PHP
autocmd FileType php call PHP()
fun! PHP()
execute “:set dictionary=C:\\dict\\PHP”
endfun ” endfun PHP

“”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"”"XML
autocmd FileType xml call XML()
fun! XML()
execute “:set dictionary=C:\\dict\\XML”
endfun ” endfun XML
“##################################################################

” This is an alternative that also works in block mode, but the deleted
” text is lost and it only works for putting the current register.
“vnoremap p “_dp

” Switch syntax highlighting on, when the terminal has colors
” Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has(“gui_running”)
syntax on
set hlsearch
endif

” Only do this part when compiled with support for autocommands.
if has(“autocmd”)

” Enable file type detection.
” Use the default filetype settings, so that mail gets ‘tw’ set to 72,
” ‘cindent’ is on in C files, etc.
” Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on

” For all text files set ‘textwidth’ to 78 characters.
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).
autocmd BufReadPost *
\ if line(“‘\”") > 0 && line(“‘\”") <= line(“$”) |
\ exe “normal g`\”" |
\ endif

endif ” has(“autocmd”)

分享家:Addthis中国
您可能还对以下文章感兴趣