Home > OS >  How do I move between splits in vim on startup?
How do I move between splits in vim on startup?

Time:06-20

I would like to open up netrw by default when editing a file, then go to edit mode within the file:

gvim -c "Vexplore" -c "startinsert" "$fileName"

Unfortunately, the cursor will be in the netrw tree, so I'd need to do a <C-w>L, but cannot figure out how ot do do that with the -c option.

CodePudding user response:

FWIW, you want <C-w>l ("move cursor to window on the right"), here, not <C-w>L ("move window to the far right").

"-c commands" are actually Ex commands so you can use the Ex command equivalent of <C-w>l, :wincmd l:

gvim -c Vexplore -c "wincmd l" -c startinsert "$fileName"

Note that the side on which :Vexplore opens a new window can be configured so "left" and "right" might not be super foolproof. These are better alternatives:

wincmd w
wincdm p

See :help :wincmd as well as :help window-move-cursor.

  • Related