<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    New

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      21 Posts :: 0 Stories :: 4 Comments :: 0 Trackbacks
    _vimrc  

    如果文件格式為java則使用indent/java.vim的縮進(jìn)規(guī)則

    autocmd FileType java source Vim/vim73/indent/java.vim
    新建一個(gè)java文件抽入指定文件

    autocmd BufNewFile *.java 0r e:/java/my.txt

    設(shè)置Tlist

    let Tlist_Show_One_File=1
    let Tlist_Exit_OnlyWindow=1  Tlist是最后一個(gè)窗口關(guān)閉時(shí)退出

    設(shè)置winmanager

    let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"
    let g:winManagerWidth = 30

    設(shè)置鍵盤(pán)映射


    nmap wm :WMToggle<cr>


    posted on 2011-10-31 22:22 H.C 閱讀(4156) 評(píng)論(2)  編輯  收藏

    Feedback

    # re: VIM for java IDE 2011-11-09 21:52 H.C
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Maintainer: amix the lucky stiff
    " http://amix.dk - amix@amix.dk
    "
    " Version: 3.6 - 25/08/10 14:40:30
    "
    " Blog_post:
    " http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
    " Syntax_highlighted:
    " http://amix.dk/vim/vimrc.html
    " Raw_version:
    " http://amix.dk/vim/vimrc.txt
    "
    " How_to_Install_on_Unix:
    " $ mkdir ~/.vim_runtime
    " $ svn co svn://orangoo.com/vim ~/.vim_runtime
    " $ cat ~/.vim_runtime/install.sh
    " $ sh ~/.vim_runtime/install.sh <system>
    " <sytem> can be `mac`, `linux` or `windows`
    "
    " How_to_Upgrade:
    " $ svn update ~/.vim_runtime
    "
    " Sections:
    " -> General
    " -> VIM user interface
    " -> Colors and Fonts
    " -> Files and backups
    " -> Text, tab and indent related
    " -> Visual mode related
    " -> Command mode related
    " -> Moving around, tabs and buffers
    " -> Statusline
    " -> Parenthesis/bracket expanding
    " -> General Abbrevs
    " -> Editing mappings
    "
    " -> Cope
    " -> Minibuffer plugin
    " -> Omni complete functions
    " -> Python section
    " -> JavaScript section
    "
    "
    " Plugins_Included:
    " > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159
    " Makes it easy to get an overview of buffers:
    " info -> :e ~/.vim_runtime/plugin/minibufexpl.vim
    "
    " > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42
    " Makes it easy to switch between buffers:
    " info -> :help bufExplorer
    "
    " > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234
    " Emacs's killring, useful when using the clipboard:
    " info -> :help yankring
    "
    " > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697
    " Makes it easy to work with surrounding text:
    " info -> :help surround
    "
    " > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540
    " Snippets for many languages (similar to TextMate's):
    " info -> :help snipMate
    "
    " > mru.vim - http://www.vim.org/scripts/script.php?script_id=521
    " Plugin to manage Most Recently Used (MRU) files:
    " info -> :e ~/.vim_runtime/plugin/mru.vim
    "
    " > Command-T - http://www.vim.org/scripts/script.php?script_id=3025
    " Command-T plug-in provides an extremely fast, intuitive mechanism for opening filesa:
    " info -> :help CommandT
    " screencast and web-help -> http://amix.dk/blog/post/19501
    "
    "
    " Revisions:
    " > 3.6: Added lots of stuff (colors, Command-T, Vim 7.3 persistent undo etc.)
    " > 3.5: Paste mode is now shown in status line if you are in paste mode
    " > 3.4: Added mru.vim
    " > 3.3: Added syntax highlighting for Mako mako.vim
    " > 3.2: Turned on python_highlight_all for better syntax
    " highlighting for Python
    " > 3.1: Added revisions ;) and bufexplorer.vim
    "
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => General
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Sets how many lines of history VIM has to remember
    set history=700

    " Enable filetype plugin
    filetype plugin on
    filetype indent on

    " Set to auto read when a file is changed from the outside
    set autoread

    " With a map leader it's possible to do extra key combinations
    " like <leader>w saves the current file
    let mapleader = ","
    let g:mapleader = ","

    " Fast saving
    nmap <leader>w :w!<cr>

    " Fast editing of the .vimrc
    map <leader>e :e! ~/.vim_runtime/vimrc<cr>

    " When vimrc is edited, reload it
    autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => VIM user interface
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Set 7 lines to the curors - when moving vertical..
    set so=7

    set wildmenu "Turn on WiLd menu

    set ruler "Always show current position

    set cmdheight=2 "The commandbar height

    set hid "Change buffer - without saving

    " Set backspace config
    set backspace=eol,start,indent
    set whichwrap+=<,>,h,l

    set ignorecase "Ignore case when searching
    set smartcase

    set hlsearch "Highlight search things

    set incsearch "Make search act like search in modern browsers
    set nolazyredraw "Don't redraw while executing macros

    set magic "Set magic on, for regular expressions

    set showmatch "Show matching bracets when text indicator is over them
    set mat=2 "How many tenths of a second to blink

    " No sound on errors
    set noerrorbells
    set novisualbell
    set t_vb=
    set tm=500


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Colors and Fonts
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    syntax enable "Enable syntax hl

    " Set font according to system
    if MySys() == "mac"
    set gfn=Menlo:h14
    set shell=/bin/bash
    elseif MySys() == "windows"
    set gfn=Bitstream\ Vera\ Sans\ Mono:h10
    elseif MySys() == "linux"
    set gfn=Monospace\ 10
    set shell=/bin/bash
    endif

    if has("gui_running")
    set guioptions-=T
    set t_Co=256
    set background=dark
    colorscheme peaksea
    set nonu
    else
    colorscheme zellner
    set background=dark

    set nonu
    endif

    set encoding=utf8
    try
    lang en_US
    catch
    endtry

    set ffs=unix,dos,mac "Default file types


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Files, backups and undo
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Turn backup off, since most stuff is in SVN, git anyway...
    set nobackup
    set nowb
    set noswapfile

    "Persistent undo
    try
    if MySys() == "windows"
    set undodir=C:\Windows\Temp
    else
    set undodir=~/.vim_runtime/undodir
    endif

    set undofile
    catch
    endtry


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Text, tab and indent related
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    set expandtab
    set shiftwidth=4
    set tabstop=4
    set smarttab

    set lbr
    set tw=500

    set ai "Auto indent
    set si "Smart indet
    set wrap "Wrap lines


    """"""""""""""""""""""""""""""
    " => Visual mode related
    """"""""""""""""""""""""""""""
    " Really useful!
    " In visual mode when you press * or # to search for the current selection
    vnoremap <silent> * :call VisualSearch('f')<CR>
    vnoremap <silent> # :call VisualSearch('b')<CR>

    " When you press gv you vimgrep after the selected text
    vnoremap <silent> gv :call VisualSearch('gv')<CR>
    map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>


    function! CmdLine(str)
    exe "menu Foo.Bar :" . a:str
    emenu Foo.Bar
    unmenu Foo
    endfunction

    " From an idea by Michael Naumann
    function! VisualSearch(direction) range
    let l:saved_reg = @"
    execute "normal! vgvy"

    let l:pattern = escape(@", '\\/.*$^~[]')
    let l:pattern = substitute(l:pattern, "\n$", "", "")

    if a:direction == 'b'
    execute "normal ?" . l:pattern . "^M"
    elseif a:direction == 'gv'
    call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
    elseif a:direction == 'f'
    execute "normal /" . l:pattern . "^M"
    endif

    let @/ = l:pattern
    let @" = l:saved_reg
    endfunction



    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Command mode related
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Smart mappings on the command line
    cno $h e ~/
    cno $d e ~/Desktop/
    cno $j e ./
    cno $c e <C-\>eCurrentFileDir("e")<cr>

    " $q is super useful when browsing on the command line
    cno $q <C-\>eDeleteTillSlash()<cr>

    " Bash like keys for the command line
    cnoremap <C-A> <Home>
    cnoremap <C-E> <End>
    cnoremap <C-K> <C-U>

    cnoremap <C-P> <Up>
    cnoremap <C-N> <Down>

    " Useful on some European keyboards
    map ½ $
    imap ½ $
    vmap ½ $
    cmap ½ $


    func! Cwd()
    let cwd = getcwd()
    return "e " . cwd
    endfunc

    func! DeleteTillSlash()
    let g:cmd = getcmdline()
    if MySys() == "linux" || MySys() == "mac"
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
    else
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
    endif
    if g:cmd == g:cmd_edited
    if MySys() == "linux" || MySys() == "mac"
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
    else
    let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
    endif
    endif
    return g:cmd_edited
    endfunc

    func! CurrentFileDir(cmd)
    return a:cmd . " " . expand("%:p:h") . "/"
    endfunc


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Moving around, tabs and buffers
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Map space to / (search) and c-space to ? (backgwards search)
    map <space> /
    map <c-space> ?
    map <silent> <leader><cr> :noh<cr>

    " Smart way to move btw. windows
    map <C-j> <C-W>j
    map <C-k> <C-W>k
    map <C-h> <C-W>h
    map <C-l> <C-W>l

    " Close the current buffer
    map <leader>bd :Bclose<cr>

    " Close all the buffers
    map <leader>ba :1,300 bd!<cr>

    " Use the arrows to something usefull
    map <right> :bn<cr>
    map <left> :bp<cr>

    " Tab configuration
    map <leader>tn :tabnew<cr>
    map <leader>te :tabedit
    map <leader>tc :tabclose<cr>
    map <leader>tm :tabmove

    " When pressing <leader>cd switch to the directory of the open buffer
    map <leader>cd :cd %:p:h<cr>


    command! Bclose call <SID>BufcloseCloseIt()
    function! <SID>BufcloseCloseIt()
    let l:currentBufNum = bufnr("%")
    let l:alternateBufNum = bufnr("#")

    if buflisted(l:alternateBufNum)
    buffer #
    else
    bnext
    endif

    if bufnr("%") == l:currentBufNum
    new
    endif

    if buflisted(l:currentBufNum)
    execute("bdelete! ".l:currentBufNum)
    endif
    endfunction

    " Specify the behavior when switching between buffers
    try
    set switchbuf=usetab
    set stal=2
    catch
    endtry


    """"""""""""""""""""""""""""""
    " => Statusline
    """"""""""""""""""""""""""""""
    " Always hide the statusline
    set laststatus=2

    " Format the statusline
    set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c


    function! CurDir()
    let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
    return curdir
    endfunction

    function! HasPaste()
    if &paste
    return 'PASTE MODE '
    else
    return ''
    endif
    endfunction


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Parenthesis/bracket expanding
    """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    vnoremap $1 <esc>`>a)<esc>`<i(<esc>
    vnoremap $2 <esc>`>a]<esc>`<i[<esc>
    vnoremap $3 <esc>`>a}<esc>`<i{<esc>
    vnoremap $$ <esc>`>a"<esc>`<i"<esc>
    vnoremap $q <esc>`>a'<esc>`<i'<esc>
    vnoremap $e <esc>`>a"<esc>`<i"<esc>

    " Map auto complete of (, ", ', [
    inoremap $1 ()<esc>i
    inoremap $2 []<esc>i
    inoremap $3 {}<esc>i
    inoremap $4 {<esc>o}<esc>O
    inoremap $q ''<esc>i
    inoremap $e ""<esc>i
    inoremap $t <><esc>i


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => General Abbrevs
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Editing mappings
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Remap VIM 0
    map 0 ^

    "Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
    nmap <M-j> mz:m+<cr>`z
    nmap <M-k> mz:m-2<cr>`z
    vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
    vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z

    if MySys() == "mac"
    nmap <D-j> <M-j>
    nmap <D-k> <M-k>
    vmap <D-j> <M-j>
    vmap <D-k> <M-k>
    endif

    "Delete trailing white space, useful for Python ;)
    func! DeleteTrailingWS()
    exe "normal mz"
    %s/\s\+$//ge
    exe "normal `z"
    endfunc
    autocmd BufWrite *.py :call DeleteTrailingWS()

    set guitablabel=%t


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Cope
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Do :help cope if you are unsure what cope is. It's super useful!
    map <leader>cc :botright cope<cr>
    map <leader>n :cn<cr>
    map <leader>p :cp<cr>


    """"""""""""""""""""""""""""""
    " => bufExplorer plugin
    """"""""""""""""""""""""""""""
    let g:bufExplorerDefaultHelp=0
    let g:bufExplorerShowRelativePath=1
    map <leader>o :BufExplorer<cr>


    """"""""""""""""""""""""""""""
    " => Minibuffer plugin
    """"""""""""""""""""""""""""""
    let g:miniBufExplModSelTarget = 1
    let g:miniBufExplorerMoreThanOne = 2
    let g:miniBufExplModSelTarget = 0
    let g:miniBufExplUseSingleClick = 1
    let g:miniBufExplMapWindowNavVim = 1
    let g:miniBufExplVSplit = 25
    let g:miniBufExplSplitBelow=1

    let g:bufExplorerSortBy = "name"

    autocmd BufRead,BufNew :call UMiniBufExplorer

    map <leader>u :TMiniBufExplorer<cr>


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Omni complete functions
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    autocmd FileType css set omnifunc=csscomplete#CompleteCSS


    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => Spell checking
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    "Pressing ,ss will toggle and untoggle spell checking
    map <leader>ss :setlocal spell!<cr>

    "Shortcuts using <leader>
    map <leader>sn ]s
    map <leader>sp [s
    map <leader>sa zg
    map <leader>s? z=


    """"""""""""""""""""""""""""""
    " => Python section
    """"""""""""""""""""""""""""""
    let python_highlight_all = 1
    au FileType python syn keyword pythonDecorator True None False self

    au BufNewFile,BufRead *.jinja set syntax=htmljinja
    au BufNewFile,BufRead *.mako set ft=mako

    au FileType python inoremap <buffer> $r return
    au FileType python inoremap <buffer> $i import
    au FileType python inoremap <buffer> $p print
    au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
    au FileType python map <buffer> <leader>1 /class
    au FileType python map <buffer> <leader>2 /def
    au FileType python map <buffer> <leader>C ?class
    au FileType python map <buffer> <leader>D ?def


    """"""""""""""""""""""""""""""
    " => JavaScript section
    """""""""""""""""""""""""""""""
    au FileType javascript call JavaScriptFold()
    au FileType javascript setl fen
    au FileType javascript setl nocindent

    au FileType javascript imap <c-t> AJS.log();<esc>hi
    au FileType javascript imap <c-a> alert();<esc>hi

    au FileType javascript inoremap <buffer> $r return
    au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi

    function! JavaScriptFold()
    setl foldmethod=syntax
    setl foldlevelstart=1
    syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend

    function! FoldText()
    return substitute(getline(v:foldstart), '{.*', '{...}', '')
    endfunction
    setl foldtext=FoldText()
    endfunction


    """"""""""""""""""""""""""""""
    " => MRU plugin
    """"""""""""""""""""""""""""""
    let MRU_Max_Entries = 400
    map <leader>f :MRU<CR>


    """"""""""""""""""""""""""""""
    " => Command-T
    """"""""""""""""""""""""""""""
    let g:CommandTMaxHeight = 15
    set wildignore+=*.o,*.obj,.git,*.pyc
    noremap <leader>j :CommandT<cr>
    noremap <leader>y :CommandTFlush<cr>


    """"""""""""""""""""""""""""""
    " => Vim grep
    """"""""""""""""""""""""""""""
    let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'
    set grepprg=/bin/grep\ -nH



    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " => MISC
    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    " Remove the Windows ^M - when the encodings gets messed up
    noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

    "Quickly open a buffer for scripbble
    map <leader>q :e ~/buffer<cr>
    au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================

    map <leader>pp :setlocal paste!<cr>

    map <leader>bb :cd ..<cr>
      回復(fù)  更多評(píng)論
      

    # re: VIM for java IDE 2011-11-11 16:25 H.C
    需要用到的插件:

    taglist需要ctags支持

    ctags.exe:http://ctags.sourceforge.net/

    taglist顯示tag列表

    taglist:http://www.vim.org/scripts/script.php?script_id=273

    顯示buf列表:

    bufexplorer:http://www.vim.org/scripts/script.php?script_id=42

    Nerd_Tree文件瀏覽

    Nerd_tree:http://www.vim.org/scripts/script.php?script_id=1658

    界面管理插件:

    winmanager:http://www.vim.org/scripts/script.php?script_id=95



    一、ctags:

    下載解壓后是源碼,感覺(jué)就那個(gè)exe文件有點(diǎn)用。直接放到一個(gè)目錄里,D:\ctags58。

    設(shè)置一下環(huán)境變量。path=D:\ctags58。這樣可以直接運(yùn)行目錄下面的ctags.exe文件。或者直接把ctags.exe放入windows的目錄里。

    vimrc中的設(shè)置:
    view sourceprint?
    1 "生成一個(gè)tags文件
    2 nmap <F9> <Esc>:!ctags -R *<CR>



    二、taglist設(shè)置:

    下載解壓到相應(yīng)的vim文件夾中。

    vimrc中設(shè)置:
    view sourceprint?
    01 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    02
    03 "設(shè)置Taglist
    04
    05 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    06
    07 " 這項(xiàng)必須設(shè)定,否則出錯(cuò),配置taglist的ctags路徑
    08
    09 let Tlist_Ctags_Cmd = 'D:\ctags58\ctags.exe'
    10
    11
    12
    13 " 不同時(shí)顯示多個(gè)文件的 tag ,只顯示當(dāng)前文件的
    14
    15 let Tlist_Show_One_File=1
    16
    17
    18
    19 " 如果 taglist 窗口是最后一個(gè)窗口,則退出 vim
    20
    21 let Tlist_Exit_OnlyWindow=1
    22
    23
    24
    25 "讓當(dāng)前不被編輯的文件的方法列表自動(dòng)折疊起來(lái)
    26
    27 let Tlist_File_Fold_Auto_Close=1
    28
    29
    30
    31 "把taglist窗口放在屏幕的右側(cè),缺省在左側(cè)
    32
    33 let Tlist_Use_Right_Window=1
    34
    35
    36
    37 "顯示taglist菜單
    38
    39 let Tlist_Show_Menu=1
    40
    41
    42
    43 "啟動(dòng)vim自動(dòng)打開(kāi)taglist
    44
    45 "let Tlist_Auto_Open=1

    啟動(dòng)自動(dòng)打開(kāi)這個(gè)選項(xiàng)暫時(shí)不設(shè)置。后面要讓winmanager調(diào)用taglist。



    三、bufexplorer:

    下載解壓,沒(méi)啥說(shuō)的。



    四、winmanager:

    下載解壓,vimrc中的設(shè)置:
    view sourceprint?
    01 """""""""""""""""""""""""""""""
    02
    03 "" winManager setting
    04
    05 """""""""""""""""""""""""""""""
    06
    07 "設(shè)置界面分割
    08
    09 "let g:winManagerWindowLayout = "BufExplorer,FileExplorer|TagList"
    10
    11 let g:winManagerWindowLayout = "TagList|FileExplorer,BufExplorer"
    12
    13
    14
    15 "設(shè)置winmanager的寬度,默認(rèn)為25
    16
    17 let g:winManagerWidth = 30
    18
    19
    20
    21 "定義打開(kāi)關(guān)閉winmanager按鍵
    22
    23 nmap <silent> <F8> :WMToggle<cr>



    以上3個(gè)插件安裝設(shè)置完畢后,基本的界面功能就可以實(shí)現(xiàn)了。按F8可以打開(kāi)/關(guān)閉界面。同時(shí)顯示taglist和fileexplorer。在fileexplorer窗口中按<c-n>可以切換到bufexplorer窗口。

    上述設(shè)置好后,有3個(gè)問(wèn)題:

    1 我想讓插件顯示在右側(cè),但是winmanager里面沒(méi)有此選項(xiàng)

    2 進(jìn)入vim時(shí)候不能自動(dòng)打開(kāi)winmanager,winmanager不像taglist支持該功能

    3 退出時(shí)不會(huì)像只有taglist時(shí)候那樣,退出當(dāng)前文件就會(huì)退出vim了

    經(jīng)過(guò)多次修改代碼終于實(shí)在了上述3個(gè)功能。



    五、將插件顯示在右側(cè)

    打開(kāi)winmanager.vim,在function! <SID>StartWindowsManager()函數(shù)中修改:

    將:wincmd H 修改為wincmd L:
    view sourceprint?
    1 " for now assume that the explorer windows always stay on the left.
    2
    3 " TODO: make this optional later
    4
    5 " make the explorers window always stay on the right ---by chenyong
    6
    7 " wincmd H
    8
    9 wincmd L



    六、進(jìn)入vim自動(dòng)打開(kāi)winmanager

    這個(gè)功能作為可選功能,我們可以在vimrc中設(shè)置:
    view sourceprint?
    1 "在進(jìn)入vim時(shí)自動(dòng)打開(kāi)winmanager
    2
    3 let g:AutoOpenWinManager = 1

    就可以讓winmanager自動(dòng)打開(kāi)。

    在winmanager.vim中修改:

    view sourceprint?
    1 "set auto open Winmanager
    2
    3 if g:AutoOpenWinManager
    4
    5 autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w
    6
    7 endif



    七、退出緩沖區(qū)時(shí),自動(dòng)退出vim

    這個(gè)功能是參考了taglist的自動(dòng)退出功能,在taglist.vim中修改的。

    函數(shù):function! s:Tlist_Window_Exit_Only_Window()中的winbunr(2)改為winbunr(3),即只剩2個(gè)窗口時(shí)關(guān)閉,考慮到2個(gè)窗口肯定是同時(shí)存在,所以這樣還是可行的:
    view sourceprint?
    01 function! s:Tlist_Window_Exit_Only_Window()
    02
    03 " Before quitting Vim, delete the taglist buffer so that
    04
    05 " the '0 mark is correctly set to the previous buffer.
    06
    07 if v:version < 700
    08
    09 if winbufnr(3) == -1
    10
    11 bdelete
    12
    13 quit
    14
    15 endif
    16
    17 else
    18
    19 if winbufnr(3) == -1
    20
    21 if tabpagenr('$') == 1
    22
    23 " Only one tag page is present
    24
    25 bdelete
    26
    27 quit
    28
    29 else
    30
    31 " More than one tab page is present. Close only the current
    32
    33 " tab page
    34
    35 close
    36
    37 endif
    38
    39 endif
    40
    41 endif
    42
    43 endfunction

    同時(shí)在vimrc中需要設(shè)置:
    view sourceprint?
    1 let Tlist_Exit_OnlyWindow=1


    winmanager自帶的fileexplorer這個(gè)插件實(shí)在是比較差。最重要的一點(diǎn)是fileexplorer不能自動(dòng)更新,如果通過(guò)其他的途徑修改了文件夾中的內(nèi)容,fileexplorer是不會(huì)顯示的。相對(duì)而言Nerd_Tree 功能就比較強(qiáng)大了。下面要把Nerd_Tree加入winmanager。

    四、Nerd_tree:

    下載解壓,打開(kāi)NERD_tree.vim,按照winmanager的說(shuō)明,在最后加入下面代碼:
    view sourceprint?
    01 "Used by winmanager {{{1
    02
    03 let g:NERDTree_title = "[NERDTree]"
    04
    05 function! NERDTree_Start()
    06
    07 exe 'NERDTree'
    08
    09 endfunction
    10
    11
    12
    13 function! NERDTree_IsValid()
    14
    15 return 1
    16
    17 endfunction

    同時(shí)把在vimrc中:
    view sourceprint?
    1 let g:winManagerWindowLayout='NERDTree|TagList,BufExplorer'

    原來(lái)的設(shè)置注釋掉。加好后,發(fā)現(xiàn)每次打開(kāi)winmanager都會(huì)出現(xiàn)一個(gè)空白的buffer。試驗(yàn)了好多次,但是Nerd_tree調(diào)用的函數(shù)就是會(huì)打開(kāi)一個(gè)新窗口。因?yàn)槿绱耍瑢ufExplorer和NERD_Tree放在一起會(huì)顯示不正常。NERD_Tree放在下面的窗口也會(huì)出錯(cuò),實(shí)在比較郁悶。。。。看了下NERD_Tree的代碼,沒(méi)看懂,只好再次改winmanager的代碼了。

    打開(kāi)winmanager.vim,找到函數(shù)function! <SID>ToggleWindowsManager(),加入兩行,修改后整個(gè)函數(shù)如下:




    view sourceprint?
    01 " toggle showing the explorer plugins.
    02 function! <SID>ToggleWindowsManager()
    03 if IsWinManagerVisible()
    04 call s:CloseWindowsManager()
    05 else
    06 call s:StartWindowsManager()
    07 " NERD_tree need this. 打開(kāi)時(shí)會(huì)有一個(gè)空白窗口,要把他關(guān)閉。
    08 exe '1wincmd w'
    09 exe 'q'
    10 end
    11 endfunction



    加個(gè)注釋,以免以后忘掉了,如果不想用nerd_Tree了,這2句話還得刪掉。



    另外打開(kāi)時(shí)的命令和關(guān)閉時(shí)的命令也得同時(shí)修改了,試驗(yàn)了很多次:

    taglist.vim中,找到下面的代碼:


    view sourceprint?
    1 " Exit Vim itself if only the taglist window is present (optional)
    2 " if g:Tlist_Exit_OnlyWindow
    3 " autocmd BufEnter __Tag_List__ nested
    4 " \ call s:Tlist_Window_Exit_Only_Window()
    5 " endif



    將這段代碼修改為:


    view sourceprint?
    01 " Exit Vim itself if only the taglist window is present (optional)
    02 let s:NERDTreeBufName = 'NERD_tree_'
    03 if g:Tlist_Exit_OnlyWindow
    04 augroup Exit_onlywindow
    05 "當(dāng)進(jìn)入Nerd_Tree的buffer時(shí)也檢測(cè)是否需要退出
    06 exec "autocmd BufEnter ". s:NERDTreeBufName .
    07 \"* call s:Tlist_Window_Exit_Only_Window()"
    08 autocmd BufEnter __Tag_List__ nested
    09 \ call s:Tlist_Window_Exit_Only_Window()
    10 augroup end
    11 endif



    winmanager中:剛才添加的自動(dòng)執(zhí)行命令要改為:


    view sourceprint?
    1 "set auto open Winmanager
    2 if g:AutoOpenWinManager
    3 " autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w
    4 autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w|q
    5 endif

    這樣所有的功能就實(shí)現(xiàn)了。在taglist窗口使用ctrl+n可以轉(zhuǎn)換到bufexplorer窗口。  回復(fù)  更多評(píng)論
      


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 中文字幕影片免费在线观看| 蜜芽亚洲av无码一区二区三区| 国产成人高清精品免费观看| 亚洲av无码国产精品色在线看不卡| 色偷偷尼玛图亚洲综合| 国产美女精品久久久久久久免费| 亚洲高清乱码午夜电影网| 国产老女人精品免费视频| 国产亚洲成在线播放va| 亚洲国产日韩成人综合天堂| 一级毛片高清免费播放| 亚洲欧洲国产精品香蕉网| 午夜视频免费在线观看| 亚洲无限乱码一二三四区| 国产卡一卡二卡三免费入口| 亚洲女子高潮不断爆白浆| 免费鲁丝片一级在线观看| 日韩久久无码免费毛片软件| 久久久久亚洲AV综合波多野结衣 | 国产亚洲精品美女久久久| 成全动漫视频在线观看免费高清版下载| 国产亚洲精品AA片在线观看不加载| 两个人看的www高清免费视频| 久久精品国产亚洲网站| 91精品国产免费久久国语麻豆| 亚洲jjzzjjzz在线观看| 国产精品国产午夜免费福利看| 一级视频在线免费观看| 亚洲国产精品不卡在线电影| 免费在线看v网址| 深夜a级毛片免费视频| 久久久久亚洲AV无码专区首| 日本阿v免费费视频完整版| 国产精品亚洲一区二区三区在线观看 | 久久亚洲精品无码AV红樱桃| 猫咪社区免费资源在线观看| 国产免费人成视频尤勿视频 | 亚洲国产精品无码专区| **aaaaa毛片免费| 国产成人综合久久精品亚洲| 亚洲精品成人网站在线观看|