在源洞察中,当连接两条线时,额外的空间将被缩小.例如:
This is line one,<space><space>
<space><space>and this is line two
Run Code Online (Sandbox Code Playgroud)
将加入:
This is line one,<space>and this is line two
Run Code Online (Sandbox Code Playgroud)
但在VIM中,join命令将产生:
This is line one,<space><space>and this is line two
Run Code Online (Sandbox Code Playgroud)
如何获得与源洞察相同的结果?
不幸的是,您无法使用选项配置它.硬编码是以这种方式检测具有尾随空格的行.并且通常不需要尾随空间.你可以认为Vim的想法是: "如果有尾随空格,保留可能很重要.否则它就不会存在".所以下一行已删除并加入了前导空格:
hello```
`there
" When joined:
hello```there
hello```
``there
" joined:
hello```there
hello````
`there
" joined
hello````there
Run Code Online (Sandbox Code Playgroud)
您可以使用地图更改此行为.这将覆盖您的
J密钥以首先删除尾随空格,然后加入这些行:
nnoremap J :s/\s*$//<cr>J
vnoremap J :s/\s*$//<cr>gvJ
Run Code Online (Sandbox Code Playgroud)