tags:

views:

41

answers:

2

I currently have the following keybinding in my .vimrc:

nnoremap <Leader>gs :Gstatus<Enter><C-n>

I'm using vim-fugitive plugin here. The intention is to pull up the Git status window and then move the cursor to the next file (<C-n>). It works, except the <C-n> part, and it seems to be because Vim executes it before the status window loads.

Is there a way to have Vim wait for the window before <C-n> is input?

A: 

Waiting for a better solution, you could try :sleep 200m to wait for 200 milliseconds…

Benoit
I gave this a try, with a well-padded value of 5000m. The delay was noticeable and occurred well after the window appeared, but seemed to also take place before the cursor was actually placed into the window, so the <C-n> still didn't have its intended effect.
Chris Vincent
A: 

You are wrong: it does not work because you use nnoremap and <C-n> is a mapping to :call search('^#\t.*', 'W')|.<CR>. You should either replace rhs with :execute ':Gstatus' \| call feedkeys("\x0E")<CR>, or replace nnoremap with nmap.

ZyX
that did the trick, thanks!
Chris Vincent
i went with replacing nnoremap with nmap.
Chris Vincent