Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command T to open file in previously opened buffer

Tags:

vim

split

I'm using Janus MacVim by Carlhuda, and I wonder if there's a way to tweak Command-T to open a file (buffer) only once, instead of into multiple splits of the same buffer.

Eg: Assumming your directory/project has two files: A.txt and B.txt.

1) Cmd T, then select A.txt.
2) Work on A.txt, then Cmd T, split B.txt with Ctrl V. 3) Work on B.txt, then need to switch back to A: Cmd T, A.txt. Currently Command T would either open A buffer to current split, or create a new split of A. What I want is that the previously opened A buffer would be active again (the cursor would jump back to A) instead of a new split A got created.

So essentially if a buffer has already been opened, resume to that split buffer. Is there a tweak or shortcuts for this?

like image 366
Alex Le Avatar asked Aug 24 '26 03:08

Alex Le


1 Answers

You probably want :drop or :tab drop instead of the default :tabe for opening files in the Command-T search buffer. This is configurable in your .gvimrc file:

function! CommandTAcceptSelectionTab()
  ruby $command_t.accept_selection :command => 'tab drop'
endfunction

This one bothered the heck out of me, too!

like image 86
bhuga Avatar answered Aug 25 '26 21:08

bhuga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!