安装
![image]()
![image]()
配置
点击查看配置 _vimrc
" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
" Mouse behavior (the Windows way)
behave mswin
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
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 arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
" jrj add begin
" 窗口大小
set lines=36 columns=136
" 显示行号
set number
set laststatus=2
"set statusline=XXXX
set tabstop=8
" 显示tab和空格
set listchars=tab:>-,lead:.,leadmultispace:...+,trail:.,extends:>,precedes:<
"set list
set nolist
set laststatus=2
"set statusline=XXXX
" vim使用的编码
set encoding=utf-8
" 文件格式
set fileformats=unix,dos
" 文件使用的编码
set fileencodings=utf-8,gb2312,ucs-bom
set guioptions+=mtgT
set guioptions+=rLb
set guioptions+=e
set showtabline=2
set guitablabel=%t%(\ [%M%R%H%W]%)
set guitabtooltip=%f
" disable ALT for menubar. use <F10> or :simalt
set winaltkeys=no
" 字体
set guifont=Consolas:h11:cANSI:qDRAFT
set scrolljump=1
set scrolloff=0
if 1
" 不需要折行显示
set nowrap
set sidescroll=1 " 类似scrolljump
set sidescrolloff=4
else
set wrap
set linebreak
endif
" 鼠标指针决定滚动的窗口
set scrollfocus
set nostartofline
" 垂直滚动
" 向下
map <A-j> 3<C-e>
imap <A-j> <ESC>3<C-e>a
" 向上
map <A-k> 3<C-y>
imap <A-k> <ESC>3<C-y>a
" 水平滚动
" 向左
map <A-h> 3zh
imap <A-h> <ESC>3zha
" 向右
map <A-l> 3zl
imap <A-l> <ESC>3zla
" 鼠标滚轮水平滚动, 参见 scroll.txt, help 'scroll'
map <S-ScrollWheelUp> <ScrollWheelLeft>
imap <S-ScrollWheelUp> <ScrollWheelLeft>
map <S-ScrollWheelDown> <ScrollWheelRight>
imap <S-ScrollWheelDown> <ScrollWheelRight>
" mark
nmap <M-`> m
nmap <C-`> :marks<CR>
" highlight
" syn match Search /PATERN/
" syn keyword Search KEYWORD
" refer cmdline.txt map.txt pattern.txt
" help iskeyword
highlight JrjHl0 guibg=white
highlight JrjHl1 guibg=green
nmap <F8> :call matchadd("JrjHl1", "\\<<C-R><C-W>\\>")<CR>
nmap <S-F8> :call matchadd("JrjHl0", "\\<<C-R><C-W>\\>")<CR>
nmap <C-F8> :call clearmatches()<CR>
" 不需要自动添加换行符
" 注意, vimrc_example.vim中配置了autocmd来设置textwidth, 应该去掉
set textwidth=10000
" 自动缩进
set autoindent
" 语法高亮
syntax on
set incsearch
set nowrapscan
set sessionoptions+=resize
set sessionoptions-=options
" 不需要备份文件
set nobackup
" 不需要undo文件
set noundofile
" swapfile
set noswapfile
set noignorecase
set nosmartcase
set nofileignorecase
set nowildignorecase
set splitright
set splitbelow
let g:netrw_browse_split=0
let g:netrw_alto=1
let g:netrw_altv=1
let g:netrw_winsize=75
let g:netrw_liststyle=1
let g:netrw_mousemaps= 0
" see also ~\vimfiles\after\ftplugin\netrw.vim; help netrw, section 10 problems and fixes
" todo
" :Explore
" autocmd FocusGained CursorHold WinEnter
" winrestview winsaveview
" noautocmd wincmd w
" netrwPlugin.vim 注册autocmd, group FileExplorer, event BufEnter
" call s:LocalBrowse
" call netrw#LocalBrowseCheck
" call s:NetrwBrowse
" call s:PerformListing
" 后退
nmap <M-1> <C-o>
" 前进
nmap <M-2> <C-i>
" ctags begin
" ctags --totals=yes --sort=yes --tag-relative=yes \
" --if0=no -h default --fields=+fkrEst --extras=+{anonymous}pFr --extras=-fq \
" --exclude="gtest" --links=no --maxdepth=6 -R -o tags .
"
" --append
" --excmd=number
" --excmd=pattern
"
" --fields=+fkrEst
" --fields-(<LANG>|all)=
" --kinds-(<LANG>|all)=
" --roles-(<LANG>|all).(<kind>|*)=
" --extras=+{anonymous}pFr
" --extras=-fq
" --extras-(<LANG>|all)=
"
" -I <identifier-list>
" -I ./ctag.d/identifier-list.file
" -D <macro>=<definition>
"
" ctags -x --kinds-c=f,v --extras=-F XX.c
"
" --options=/PATH/TO/conf.ctags # one option per line
" OR ctags.d/conf.ctags in HOMEDIR or CURDIR
"
" ctags --list-features
" ctags --list-excludes
" ctags --list-languages
" ctags --list-fields=<LANG>
" ctags --list-kinds-full=<LANG>
" ctags --list-roles=<LANG>
" ctags --list-extras=<LANG>
" ctags --list-pseudo-tags
set tagcase=match
set tagbsearch
set tagstack
set tagrelative
set tags=./tags,tags
" 后退
nmap <M-q> :pop<CR>
" 前进
nmap <M-w> :tag<CR>
let $PATH .= ";E:/program/cygwin/bin"
let Tlist_Ctags_Cmd="ctags.exe"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_WinWidth=40
let Tlist_Inc_Winwidth=0
let Tlist_Auto_Update=0
let Tlist_Auto_Highlight_Tag=0
let Tlist_Highlight_Tag_On_BufEnter=0
" ctags end
" 如果是双击启动vim(非 vim FILELIST 形式),启动netrw
if argc(-1) == 0
cd D:\
" help 'shortmess'
"silent edit ./
"silent 35vsplit ./
endif
" cscope begin
" cscope -b -k -R ./ -- ?
" cscope -b -k -i cscope.files
" cscope add ./cscope.out
set cscopeprg=E:\program\cygwin\bin\cscope.exe
set cscoperelative
set cscopequickfix=s+,d+,c+,t+,e+,i+,a+
set nocscopetag
set cscopetagorder=0
set cscopeverbose
set cscopepathcomp=8
" 0 or s: Find this C <symbol>
" 1 or g: Find this <global> definition
" 2 or d: Find functions <called> by this function
" 3 or c: Find functions <calling> this function
" 4 or t: Find this <text> string
" 6 or e: Find this <egrep> pattern
" 7 or f: Find this <file>
" 8 or i: Find files <#including> this file
" 9 or a: Find <assignments> to this symbol
nmap <C-/>s :lcs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>g :lcs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>d :lcs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>c :lcs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>t :lcs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>e :lcs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-/>f :lcs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-/>i :lcs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-/>a :lcs find a <C-R>=expand("<cword>")<CR><CR>
" csope end
" todo taglist tag-highlight preview-window
let g:jrj_winmain=win_getid()
let g:jrj_winnetrw=0
"let g:jrj_wintlist=0
let g:jrj_netrwopen=0
let g:jrj_prevlocopen=0
function JrjBufdir()
let idx = strridx(bufname(), "\\")
if idx == -1 | return "." | endif
return strpart(bufname(), 0, idx + 1)
endfunction
function JrjNetrwToggle()
if g:jrj_netrwopen == 0
call win_gotoid(g:jrj_winmain)
execute ("42vsplit " . getcwd(-1, 0))
set winfixwidth
let g:jrj_winnetrw=win_getid()
let g:netrw_chgwin=win_id2win(g:jrj_winmain)
let g:jrj_netrwopen=1
call win_gotoid(g:jrj_winmain)
else
call win_gotoid(g:jrj_winnetrw)
q
let g:jrj_winnetrw=0
let g:jrj_netrwopen=0
call win_gotoid(g:jrj_winmain)
endif
endfunction
function JrjTlistToggle()
call win_gotoid(g:jrj_winmain)
TlistToggle
let g:netrw_chgwin=win_id2win(g:jrj_winmain)
endfunction
"nmap <C-1> :25Lexplore!<CR>
"nmap <C-1> :execute ("45vsplit " . strpart(bufname(), 0, strridx(bufname(), "\\") + 1))<CR>
"nmap <C-1> :execute ("45vsplit " . getcwd(-1, 0))<CR>
"nmap <C-1> :execute ("45vsplit " . JrjBufdir())<CR>:execute ("NetrwC" . winnr())<CR>:set buftype=nofile<CR>
"nmap <C-1> :exe(g:jrj_winmain . "wincmd w")<CR>:execute ("45vsplit " . getcwd(-1, 0))<CR>:set winfixwidth<CR>:wincmd p<CR>:let g:jrj_winmain=winnr()<CR>:let g:netrw_chgwin=g:jrj_winmain<CR>
"nmap <C-2> :exe(g:jrj_winmain . "wincmd w")<CR>:TlistToggle<CR>:let g:jrj_winmain=winnr()<CR>:let g:netrw_chgwin=g:jrj_winmain<CR>
"nmap <C-3> :execute ("botright pedit")<CR>
"nmap <C-4> :wincmd P<CR>:vertical copen 80<CR>
nmap <C-1> :call JrjNetrwToggle()<CR>
nmap <C-2> :call JrjTlistToggle()<CR>
function JrjNewLoclist()
let loctitle = strftime("%c")
call setloclist(g:jrj_winmain, [], ' ', {'title' : loctitle})
endfunction
function JrjClrLoclist()
call setloclist(g:jrj_winmain, [], 'r', {'items' : []})
endfunction
function JrjPrevLocToggle()
call win_gotoid(g:jrj_winmain)
if g:jrj_prevlocopen == 0
call JrjNewLoclist()
botright lopen 14
set winfixheight
vertical aboveleft new
set previewwindow
let g:jrj_prevlocopen=1
else
pclose
lclose
let g:jrj_prevlocopen=0
endif
call win_gotoid(g:jrj_winmain)
endfunction
nmap <C-3> :call JrjPrevLocToggle()<CR>
nmap <F5> :call JrjNewLoclist()<CR>
nmap <S-F5> :call JrjClrLoclist()<CR>
nmap <M-3> :exe(win_id2win(g:jrj_winmain) . "wincmd w")<CR>:execute ("ptag " . expand("<cword>"))<CR>
"nmap <M-4> :TlistUpdate<CR>:wincmd h<CR>:wincmd l<CR>
nmap <M-4> :TlistHighlightTag<CR>
nmap <M-5> :exe(win_id2win(g:jrj_winmain) . "wincmd w")<CR>:TlistUpdate<CR>:exe((win_id2win(g:jrj_winmain)-1) . "wincmd w")<CR>:exe(win_id2win(g:jrj_winmain) . "wincmd w")<CR>
" jrj add end