Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind a key to open the highlighted file with vim?

Tags:

vim

tmux

If I highlighted a filename in the copy mode, how could I open that file with vim by a hotkey?

I'm imagining something like:

bind-key -T copy-mode-vi 'C-o' send-keys -X copy-pipe-and-cancel "vim $(tmux paste-buffer)"

but that doesn't work, plus piping is redundant in this case.

I know there is tmux-open which should do similar thing, but it doesn't work for me somehow.

Environment: OSX 10.13.5, iTerm2 3.1.7, Tmux stable 2.7 built by homebrew

like image 728
southp Avatar asked Dec 06 '25 05:12

southp


1 Answers

I normally have these settings in my vimrc

set hidden 
set path+=**

Then you can just press gf when you cursor is over a word. If you want to open it on a new window, press Ctrl-w gf. If you just use gf you can go back by pressing Ctrl-6.

like image 61
SergioAraujo Avatar answered Dec 08 '25 19:12

SergioAraujo



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!