tags:

views:

141

answers:

1

I get the old buffers to be opened when I press

Ctrl-O

I want only to browse buffers which I have opened in the current Vim session.

How can you browse fast between current buffers in Vim with Ctrl-O?

+3  A: 

Hello, unfortunately I don't know how to make CTRL-O to behave the way you'd like. But I can offer you a couple of tips that might be helpful to you.

  1. You can use g; and g, to jump to the places where you have made a change, but only in the current buffer.

    I know this is not the same as CTRL-O/I, since this is only about "changes", and it only tracks the current buffer, but it might be useful anyway.

  2. You can quickly navigate your opened buffers with a mapping in your .vimrc like this:

    nmap <special> <C-Up> :bnext<CR>
    nmap <special> <C-Down> :bprevious<CR>
    

I know this doesn't really answer your question, but I thought that maybe these couple of tips might help a little with your vimming.


Edit: I wanted to add, that since you are interested in fast browsing of buffers, I personally recommend a little plugin called QuickBuf:

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

I map it in my .vimrc as this:

let g:qb_hotkey = ",b"

Try it, it way faster than typing :ls and another neat thing is that you can move on the list with j/k and press <enter> to select the buffer.

Jorge Gajon
@Jorge: How can you use the nmap -codes above? I put them to my .vimrc, and I pressed Ctrl-<Upward Key> but nothing happened.
Masi
Do you know how you can remap jk to ht in the plugin? I am using Dvorak.
Masi
@Masi, I had the same problem with an rxvt terminal, maybe that is also your case. What I did was to change the mappings to this: nmap ^[0a :bnext<CR> and nmap ^[0b :bprevious<CR> For some reason in rxvt pressing the Up and Down keys while holding CTRL sends the escape codes ESC[0A and ESC[0B.
Jorge Gajon
@Masi, also, if you are still getting problems, you can figure out what codes your vim or gvim is getting while pressing CTRL-Up/Down. To do that enter --INSERT-- mode and press CTRL-V and then press either CTRL-Up or CTRL-Down. I get <C-Up> in gvim, ^[[1;5A in xterm, and ^[0a in rxvt, while pressing CTRL-Up.
Jorge Gajon
@Masi, regarding jk, these keys are next to each other on the left hand in the dvorak layout. Why do you want to remap them? In any case, if you want to modify the plugin to use ht to move up/down, open the plugin source and look around lines 86, 88, 110, 114 and 115. You can figure it out.
Jorge Gajon
+1 especially for the quickbuf link - hadn't seen that one.
Andy
@Jorge: Thank you for your answer! I will leave jk, since they are as easy as ht.
Masi