Ken*_*Ken 5 vim keyboard-shortcuts heredoc
Vim的一大优势是对象选择,可快速处理单词,段落和各种分隔符内的内容.
例如,
vi{
Run Code Online (Sandbox Code Playgroud)
将选择一对{}括号内的所有内容.
是否有任何等效功能来选择here here或heredoc:
<<<HTML
....
....
HTML;
Run Code Online (Sandbox Code Playgroud)
基于ErichBSchulz的回答,我想出了一个heredoc内部选择的以下内容:
nmap <F6> ?<<<<CR>w*kV?<<<<CR>j
?<<<<CR>w " find beginning tag (after <<<)
*k " find matching end tag and go up 1 line
V " enter visual mode
?<<<<CR>j " find beginning tag and go down 1 line
Run Code Online (Sandbox Code Playgroud)
思考之前的帖子并尝试让它们更近一步。这不会是 100% 可靠的(即,如果起始标签出现在 Heredoc 中,则会中断,但类似:
?<<< "find begining
w " go to starting tag
* " find starting tag
v " enter visual mode (could use Upper V to do an 'ambientish' object select
n " find end tag
e " optional include end tag
Run Code Online (Sandbox Code Playgroud)
编辑:Ken 改进了上述序列,所以我建议您使用他更好的键映射来进行“内部”heredoc 选择:
nmap <F6> ?<<<<CR>w*kV?<<<<CR>j
Run Code Online (Sandbox Code Playgroud)
(这是基于 php 风格的heredocs)