开发者

Waiting for window before executing a command for Vim keybinding?

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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜