[Reprinted] howto uses Vim's minibuf to switch the buffer

Source: Internet
Author: User

Reprinted from: http://linux.bloghome.cn/posts/114.html

1. Install to http://vim.sourceforge.net/scripts/script.php? Script_id = 1, 159

Download the latest minibufexpl. Vim script,
Copy the file to the plugin directory.

2. Configuration
Add the following to the configuration file. vimrc:
"
"Minibuf plugin
"
Let G: minibufexplmapwindownavvim = 1 "Ctrl-Let G: minibufexpltabwrap = 1 "make tabs show complete (no broken on two lines)

In this way, you can use minibuf, and set Ctrl-H/J/k/L to switch in various windows, which is very convenient.
TIPS:
1. minibuf occupies a window. You can use ctrl-K to switch to it, and then press <tab> to select Buffer cyclically,
Press <enter> to activate the buffer. Press d to delete the buffer.
2. There is a number before each buffer name, which is the buffer number. Therefore, you can enter B <buffer number> to quickly switch.

Self-declared, I am a lazy, so I set several shortcut keys:
<F1> switch to the previous buffer zone
<F2> switch to the next buffer zone
<F3> Save the buffer (: Update)
<F4> disable the buffer (: BD, or: bdelete, delete the buffer)
The script is as follows: Nnoremap < F1 > : Call mycyclebuffer ( 0 ) < Cr >
Nnoremap < Leader > 1 : Call mycyclebuffer ( 0 ) < Cr >
Inoremap < F1 >   < ESC > : Call mycyclebuffer ( 0 ) < Cr >
Nnoremap < F2 > : Call mycyclebuffer ( 1 ) < Cr >
Nnoremap < Leader > 2 : Call mycyclebuffer ( 1 ) < Cr >
Inoremap < F2 >   < ESC > : Call mycyclebuffer ( 1 ) < Cr >
" Cycle through Buffers
" From minibufexplorer, modified by djw
Function ! Mycyclebuffer (forward)
" Change buffer (keeping track of before and after buffers)
Let L: origbuf = Bufnr ( '' % '' )
If (A: Forward =   1 )
BN !
Else
BP !
Endif
Let L: curbuf = Bufnr ( '' % '' )
" Skip any non-modifiable buffers, but don't cycle forever
" This shoshould stop us from stopping in any of the [schedulers]
While Getbufvar (L: curbuf, '' & Modifiable '' ) =   0   && L: origbuf ! = L: curbuf
If (A: Forward =   1 )
BN !
Else
BP !
Endif
Let L: curbuf = Bufnr ( '' % '' )
Endwhile
Endfunction

" <F4> Delete Buffer
Nnoremap < F4 > : BD < Cr >
Nnoremap < Leader > 4 : BD < Cr >
Inoremap < F4 >   < ESC > : BD < Cr >

" <F3> or Ctrl-s update Buffer
Nnoremap < C - S > : Update < Cr >
Inoremap < C - S >   < C - O > : Update < Cr >
Vnoremap < C - S >   < C - C > : Update < Cr >
Nnoremap < F3 > : Update < Cr >
Inoremap < F3 >   < C - O > : Update < Cr >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.