【发布时间】:2017-03-13 21:44:19
【问题描述】:
putting 在 Vim 中输入文本时遇到问题。
假设我想将我的 /* Comment */ 行粘贴到 $('table').append 行下方...
/* Comment */
for (var i=1; i<=lineLength ; i++) {
$('table').append('<tr></tr>');
for (var j=1; j<=lineLength; j++) {
$('table tr:nth-last-child(1)').append('<td></td>');
}
}
在大多数文本编辑器中,我的工作流程是
- 选择
/* Comment */,点击剪切。 - 将光标移动到第一行代码的末尾并按回车键。
- 文本编辑器自动缩进,我只是点击粘贴。
即
/* Comment */
for (var i=1; i<=lineLength ; i++) {
$('table').append('<tr></tr>');
| <==Pipe is position of cursor before paste; pasted lines are inserted here.
for (var j=1; j<=lineLength; j++) {
$('table tr:nth-last-child(1)').append('<td></td>');
}
}
但是使用 vim,我似乎必须这样做:
- 移至
/* Comment */行,点击dd。 - 移至
$('table').append行,点击p。
新代码:
for (var i=1; i<=lineLength ; i++) {
$('table').append('<tr></tr>');
/* Comment */. <== Comment is not correctly indented.
for (var j=1; j<=lineLength; j++) {
$('table tr:nth-last-child(1)').append('<td></td>');
}
}
- 手动修复不正确缩进的代码。
当我用o 开始一个新行时,Vim 自动缩进很好,所以它似乎也应该将putting 处理到一个新行......有没有一个命令可以让我put new具有正确缩进的代码行?
【问题讨论】:
标签: vim indentation copy-paste paste auto-indent