Wednesday, January 1, 2014

Re: Swapping between 3 or 4 buffers [Was: Retaining window layout]

On 22:47 Wed 01 Jan , Erik Christiansen wrote:
> On 01.01.14 11:07, Marcin Szamotulski wrote:
> > On 20:01 Tue 31 Dec , Dejan Ranisavljevic wrote:
> > > Ideally i would delete that new buffer and get a previous buffer i was working on.
> ...
>
> > :BufWipe commands to delete/wipe out a buffer but do not close the
> > window. They do not open previous buffer, but leave you with a new one,
> > so you can choose a buffer to load with :e or :b commands.
>
> I wonder, is there also an easier way to a similar workflow when using
> plain buffers? (No windowy stuff) Yes, ^ is marvellous for alternating
> between one program file and another with e.g. function definitions, but
> when we also need to flick over to a header or library file, it's back to
> :bu second_last_file_accessed. (OK, autocompletion of partial filenames is
> _brilliant_, but is there more? :)
>
> We have ^O and ^I to eventually work our way between recent files, via
> many intervening moves within each file. Are there perhaps variants of
> ^O and ^I which move back and forth by file, skipping intra-file dances?
> Maybe it's wishful thinking, but it would be awfully convenient.
>
> Erik
>
> --
> The Heineken Uncertainty Principle:
>

I wrote a map for that, but I haven't made it public, yet:

fun! FileJump(count, ...)
let backward = (a:0 >= 1 ? a:1 : 'b')
let ind = (backward == 'b' ? -1 : 1)
for x in range(a:count)
let file = expand('%:p')
while file == expand('%:p')
let line = line('.')
if ind == 1
exe "normal! 1\<C-I>"
else
exe "normal! 1\<C-O>"
endif
if line == line('.') && file == expand('%:p')
break
endif
endwhile
endfor
endfun
nm <Leader><c-o> :<c-u>call FileJump(v:count1, 'b')<cr>
nm <Leader><c-i> :<c-u>call FileJump(v:count1, 'f')<cr> You can never be sure how many beers you had last night.

Best regards,
Marcin

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment