gf
.Find a solution that makes gf
work with tab-page
as the default behavior.
The current default behavior opens the new file in the same viewport, but sometimes a user might want to open the new file in a different tab using the Vim tab-page
feature.
Alternatively, a user may wish to always have gf
use tab-page and never open the linked file in the same viewport.
Vim allows the gf
command to open in a new tab, but it requires the user to type control-W <C-W>
before invoking gf
.
The existing approach is not optimal, because the keystrokes are cumbersome and introduce the risk of repetitive strain injury for users who make heavy use of the gf
command.
Vim help:
It would be desirable to do away with the need to type <C-W>gf
all the time, in order to save keystrokes and reduce the risk of repetitive strain injury.
The following attempt did not work (use a normal command):
:normal <C-W>gf
:normal <C-W>gf
work as expected?The answer to your first question:
What comes after :normal
is supposed to be raw key presses, as you'd type them in normal mode. What you used means nothing so it does nothing (you are lucky, it could mean something and ruin your entire buffer!).
It would work if you inserted the raw representation of <C-w>
:
:norm <C-v><C-w>gf
which should look like:
:norm ^wgf
The answer to your second question:
nnoremap gf <C-w>gf