Running a vim key combination on startup
The command to go to the window to the right is <C-w>l
. You can execute that with
:execute "normal! \<C-w>l"
But for the <C-w>
commands, there's a special :wincmd
that makes this easier. So just skip your custom mapping, and do:
autocmd VimEnter ...
autocmd VimEnter * wincmd l
Related videos on Youtube
Jules
Expert Python programmer with experience working with the Linux network stack, REST APIs, and relational databases (and Postgres in particular). There's some devops experience in there too, but software dev is my preference. Not currently open to new work.
Updated on September 18, 2022Comments
-
Jules over 1 year
In my
.vimrc
, I've got the linesautocmd VimEnter * NERDTree autocmd VimEnter * TagbarOpen
This results in a layout with two sidebars and a centre column containing the main editing buffer (i.e. the file I'm editing), but with the cursor in the NERDTree sidebar - resulting in the Tagbar being collapsed by default. What I want to do is execute the keystroke combination
<C>l
(which I've mapped to the command to move the cursor one buffer to the right) between the NERDTree opening and the Tagbar being toggled - but so far, I haven't managed to get the cursor to move. So far, i've tried using bothautocmd VimEnter * <C>l autocmd VimEnter * normal <Ctrl+l>
... between the two above first lines, but neither of these work.
How do I go about this?
-
savanto almost 10 yearspossible duplicate of VIM Executing a key command in a function
-
savanto almost 10 yearsSee the link above. You can put
execute "normal \<C-L>"
in your.vimrc
. -
Jules almost 10 yearsThat solution and the answers in the linked-to question don't work.
-
savanto almost 10 yearsYou're right, the questions are not really duplicates. I've combined the information from that link with what you had so far. Please take a look below and let me know if it works.
-