2017-01-23 41 views
3
模式

我在我的vimrc定義自己的命令:切換到** **插入從一個用戶定義的命令在Vim中

command! Tcs :normal lvf`hc 

的目的是,我去一個反引號,它會刪除內容從這裏到下一個反襯。像:

`hi there` -> `` 

問題是保持在正常模式下,我想複製c命令的行爲,這樣我就可以開始在插入模式立即打字。

我試過command! Tcs :normal lvf`hc :startinsert但是我在最後的c之後所做的任何操作都將直接在編輯器中輸入。

由於

+2

的,什麼是錯** ** ci'(** C ** **焊割我** n面反引號) ?!!!這是一個內置的正常模式命令,即使您不在反引號之間也可以正常工作。 – dNitro

回答

1

:help :normal >

 :norm[al][!] {commands}     *:norm* *:normal* 
     (...) 
     {commands} should be a complete command. If 
     {commands} does not finish a command, the last one 
     will be aborted as if <Esc> or <C-C> was typed.    

This implies that an insert command must be completed

 (...) 

在你的情況下,命令normal已被中止,這就是爲什麼你仍然在正常模式。您仍然可以嘗試:normal! i

爲了得到你想要的東西,而不是你可以這樣做:

command! Tcs execute "normal lvf`hd" | :startinsert 
+1

它的作品,謝謝!我其實讀過這些幫助,但我無法理解你解決問題的方式。我會說這有點模糊。 – pietro909

相關問題