我有時會發現自己正在編寫文本,其中部分文件是由外部程序生成的。例如,考慮包含vim:執行光標後的其餘行作爲vim命令
/*
* To regenerate the following data, place the cursor at the beginning
* of the next line after this comment, then run
* ma:r!find /foo -name '*.in' | xargs whatever | some complicated processing
* and merge the result with
* 'a!}sort -u
*/
some
generated
stuff
here
我最終使用鼠標來選擇第一命令(ma:...
),粘貼&運行它C源文件,等待命令完成,選擇'a!}sort -u
並粘貼&運行它。這是不雅的,因爲它只是半自動的,我認爲它可以是全自動的。我閱讀:execute
和朋友的vim在線幫助,但它看起來像沒有做我想做的事。我正在考慮用適當的命令填充vim寄存器,然後執行寄存器內容。在線:help registers
到目前爲止沒有給出線索。
理想的情況下,新的評論會說像
/*
* To regenerate the following data, place the cursor on the 'j' on the
* next line in this comment, then execute it with <SHORT-MAGIC-VIM-INCANTATION>
* jjma:r!find /foo -name '*.in' | xargs whatever | ...<CR>'a!}sort -u<CR>
*/
如何才能實現這一目標?
哦aha。':@ z'用於寄存器比'^ R'寄存器'完成'更容易(也可以描述)+1 – sehe
'nnoremap'不會將光標移動到適當的行。修改修復了這個問題:'「zy $ 2j:@z'。 –
Jens