How do you prefer to switch between buffers in Vim?

前端 未结 16 2099
小蘑菇
小蘑菇 2020-12-12 08:33

I\'ve tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I\'d like is something like LustyJuggler with incremental sear

16条回答
  •  隐瞒了意图╮
    2020-12-12 09:20

    I have been using Wincent Colaiuta's Command-T vim plugin for a couple months now. Wincent wrote the parts of it that need to be fast in C, and I must say that it is! And, I think its file pattern matching logic is even better than Textmate's Command-T. Check out the screencast.

    The Command-T plug-in for VIM provides an extremely fast, intuitive mechanism for opening files with a minimal number of keystrokes. It's named "Command-T" because it is inspired by the "Go to File" window bound to Command-T in TextMate.

    Files are selected by typing characters that appear in their paths, and are ordered by an algorithm which knows that characters that appear in certain locations (for example, immediately after a path separator) should be given more weight.

    Easier buffer switching contains many useful tips. I have adapted the following to my .vimrc, which does buffer-name auto-completion, maps the most useful buffer-switching commands to my and left-side home row keys, and shows the current buffer number in the status line:

    "" Tab triggers buffer-name auto-completion
    set wildchar= wildmenu wildmode=full
    
    let mapleader = ","
    
    map t :CommandT
    map a :bprev
    map s :bnext
    map d :bd
    map f :b 
    
    "" Show the buffer number in the status line.
    set laststatus=2 statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
    

    I also use MiniBufExplorer, which provides a compact listing of each listed buffer in its own horizontal split up top.

提交回复
热议问题