|
|
无双 loveunix.net
http://www.loveunix.net/bbs/inde ... amp;CODE=00&f=9
我:
C-N C-P 词完成
C-F 文件名完成 可以使用C-N C-P查找上一个 下一个
C-L 行完成
gg=G 代码对齐 (不喜欢写文章 不然可能会试用gggqG)
:%s/\s\+$//g 去掉行尾空格
:%s/\r//g 去掉^M形式的字符 ,另外请设置 set ffs=unix 保证vim不会自动转换^M成\n
然后是目录的打开与关闭了 zM zC cn等 这个写在vim配置文件中的 使用grep时很有用
偶尔也使用
C-E C-Y来复制上行 /下行的字
* # 快速查找
C-r C-w 复制词到命令行上
另外 偶尔使用ctags 进行跳转 但多数会使用cscope查找
喜欢的插件是 a.vim 在.h与对应的c/cpp中切换
doxgen.vim 名字记不全 可以到vim.sf.net上查找dox插件 自动给函数添加doxgen格式注释的
bufexplore.vim winmanage.vim 完成文件列表与buf列表功能
taglist.vim 列出函数列表
还有c.vim 添加c类型的注释
喜欢使用配置文件中的命令 :
F3 F4 F5 F6 打开关闭代码块 看的方便
附 vim配置文件:
- set nocompatible
- source $VIMRUNTIME/vimrc_example.vim
- source $VIMRUNTIME/mswin.vim
- behave xterm
- set ffs=unix
- 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
- silent execute '!D:\tools\gnu\Vim\vim63\diff ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
- endfunction
- hi HL_HiCurLine ctermfg=blue ctermbg=cyan guifg=blue guibg=cyan
- let HL_HiCurLine= "HL_HiCurLine"
- set formatoptions=tcrqn2
- set guifont=FixedsysTTF:h14 "如果没有这个字体那就不要加
- set tabstop=8
- set softtabstop=4
- set shiftwidth=4
- colorscheme ps_color "在gvim下可以看到有多少coloscheme
- set lsp=0
- set sw=4 " shiftwidth
- set et " expandtab
- "set wm=8 " wrapmargin
- set bs=2 " backspace
- set ru " ruler
- set ic " ignorecase "忽略大小写 但是输入中有大写的话不忽略
- set is " incsearch
- set scs " smartcase: override the 'ic' when searching
- " if search pattern contains uppercase char
- set wmnu
- set wildignore=*.bak,*.o,*.e,*~
- iab #i #include
- iab #d #define
- iab #e #endif
- set cst
- set csto=1
- "D:\tools\dev\Microsoft Visual Studio\VC98\MFC\Include\tags
- "D:\tools\dev\Microsoft Visual Studio\VC98\Include\tags
- "C:\Symbian\UIQ_21\epoc32\include\tags
- set tags=./tags,../tags,../../tags,../../../tags,D:/tools/dev/Microsoft\ Visual\ Studio/VC98/Include/tags
- set cspc=3 " show file path's last three part
- set grepprg=grep\ -nH
- map <F1> :Tlist<cr>
- map <F2> :WMToggle<cr>
- map <F3> zO
- map <F4> zc
- map <F5> zR
- map <F6> zM
- map <F7> :cn<CR>
- "
- set vb t_vb= " set visual bell and disable screen flash
- set backup " enable backup and define the backup file
- set backupext=.bak
- set hlsearch " hlsearch
- " allow backspacing over everything in
- " the insert mode
- set backspace=indent,eol,start
- set dir=D:\tmp\vim
- " 设置swap文件的目录上面
- set backupdir=D:\tmp\vim
- "设置备份文件的目录上面 我不喜欢看到每个目录下都有备份 因为一般备份用不到
- "下面是设置自动folder的 而且是根据写C代码设置的 如果你不喜欢使用folder那么可以省略掉
- "au BufReadPost *.h,*.c,*.cpp,*.java,*.pl syn region myFold start="{" end="}" transparent fold
- "au BufReadPost *.h,*.c,*.cpp,*.java,*.pl syn sync fromstart
- "au BufReadPost *.h,*.c,*.cpp,*.java,*.pl set foldmethod=syntax
- "set foldlevel=0
- set foldmarker={,}
- set foldmethod=marker
- set foldlevel=100 " Don't autofold anything (but I can still fold manually)
- set foldopen-=search " don't open folds when you search into them
- set foldopen-=undo " don't open folds when you undo stuff
- "-------------------------------------------------------------------------------
- " C-support.vim
- "-------------------------------------------------------------------------------
- let g:C_AuthorName = 'Zhonglei Li'
- let g:C_AuthorRef = ''
- let g:C_Email = 'Zhonglei_Li@trendmicro.com.cn'
- let g:C_Company = 'Trend Micro Incorporated'
- "-------------------------------------------------------------------------------
- " copy from web
- "-------------------------------------------------------------------------------
- set history=1000 " How many lines of history to remember
- set cf " enable error files and error jumping
- set clipboard+=unnamed " turns out I do like is sharing windows clipboard
- set ffs=dos,unix,mac " support all three, in this order
- filetype plugin on " load filetype plugins
- set viminfo+=! " make sure it can save viminfo
- set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them not be
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Vim UI
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- set lsp=0 " space it out a little more (easier to read)
- set wildmenu " turn on wild menu
- set ruler " Always show current positions along the bottom
- set cmdheight=1 " the command bar is 2 high
- "set number " turn on line numbers
- set lz " do not redraw while running macros (much faster) (LazyRedraw)
- "set hid " you can change buffer without saving
- set backspace=2 " make backspace work normal
- set whichwrap+=<,>,h,l " backspace and cursor keys wrap to
- set mouse=a " use mouse everywhere
- set shortmess=atI " shortens messages to avoid 'press a key' prompt
- set report=0 " tell us when anything is changed via :...
- set noerrorbells " don't make noise
- " make the splitters between windows be blank
- set fillchars=vert:\ ,stl:\ ,stlnc:\
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Visual Cues
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "set showmatch " show matching brackets
- "set mat=5 " how many tenths of a second to blink matching brackets for
- "set nohlsearch " do not highlight searched for phrases
- set incsearch " BUT do highlight as you type you search phrase
- set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when I hit :set list
- set lines=80 " 80 lines tall
- set columns=160 " 160 cols wide
- set so=0 " Keep 10 lines (top/bottom) for scope
- set novisualbell " don't blink
- set noerrorbells " no noises
- set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
- set laststatus=2 " always show the status line
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Text Formatting/Layout
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- set fo=tcrqn " See Help (complex)
- "set ai " autoindent
- "set si " smartindent
- "set cindent " do c-style indenting
- "set tabstop=8 " tab spacing (settings below are just to unify it)
- "set softtabstop=8 " unify
- "set shiftwidth=8 " unify
- "set noexpandtab " real tabs please!
- "set nowrap " do not wrap lines
- "set smarttab " use tabs at the start of a line, spaces elsewhere
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Folding
- " Enable folding, but by default make it act like folding is off, because folding is annoying in anything but a few rare cases
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "set foldenable " Turn on folding
- "set foldmethod=indent " Make folding indent sensitive
- "set foldlevel=100 " Don't autofold anything (but I can still fold manually)
- "set foldopen-=search " don't open folds when you search into them
- "set foldopen-=undo " don't open folds when you undo stuff
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " File Explorer
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let g:explVertical=1 " should I split verticially
- let g:explWinSize=20 " width of 35 pixels
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Win Manager
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let g:winManagerWidth=20 " How wide should it be( pixels)
- let g:winManagerWindowLayout = 'FileExplorer,TagsExplorer|BufExplorer' " What windows should it
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " CTags
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "let Tlist_Ctags_Cmd = $VIM.'\ctags.exe' " Location of ctags
- let Tlist_Sort_Type = "name" " order by
- "let Tlist_Use_Right_Window = 1 " split to the right side of the screen
- let Tlist_Compart_Format = 1 " show small meny
- let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself
- let Tlist_File_Fold_Auto_Close = 0 " Do not close tags for other files
- let Tlist_Enable_Fold_Column = 0 " Do not show folding tree
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Minibuf
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines)
- "let g:miniBufExplModSelTarget = 1
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Matchit
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let b:match_ignorecase = 1
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Perl
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let perl_extended_vars=1 " highlight advanced perl vars inside strings
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Custom Functions
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Select range, then hit :SuperRetab($width) - by p0g and FallingCow
- function! SuperRetab(width) range
- silent! exe a:firstline . ',' . a:lastline . 's/\v%(^ *)@<= {'. a:width .'}/\t/g'
- endfunction
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Mappings
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "map <right> <ESC>:MBEbn<RETURN> " right arrow (normal mode) switches buffers (excluding minibuf)
- "map <left> <ESC>:MBEbp<RETURN> " left arrow (normal mode) switches buffers (excluding minibuf)
- "map <up> <ESC>:Sex<RETURN><ESC><C-W><C-W> " up arrow (normal mode) brings up a file list
- "map <down> <ESC>:Tlist<RETURN> " down arrow (normal mode) brings up the tag list
- "map <A-i> i <ESC>r " alt-i (normal mode) inserts a single char, and then switches back to normal
- "map <F2> <ESC>ggVG:call SuperRetab()<left>
- "map <F12> ggVGg? " encypt the file (toggle)
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Autocommands
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
- "au BufNewFile,BufRead *.asp :set ft=aspjscript " all my .asp files ARE jscript
- "au BufNewFile,BufRead *.tpl :set ft=html " all my .tpl files ARE html
- "au BufNewFile,BufRead *.hta :set ft=html " all my .tpl files ARE html
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Useful abbrevs
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- "iab xasp <%@language=jscript%><CR><%<CR><TAB><CR><BS>%><ESC><<O<TAB>
- "iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
复制代码 |
|