I'm having trouble when putting
text in Vim.
Say I want to paste my /* Comment */
line below the $('table').append
line...
/* 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>');
}
}
In most text editors, my workflow would be
/* Comment */
, hit cut.i.e.
/* 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>');
}
}
But with vim, it seems like I have to do this:
/* Comment */
line, hit dd
.$('table').append
line, hit p
.New code:
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>');
}
}
Vim auto-indents fine when I start a new line with o
, so it seems like it should also handle putting
onto a new line.... Is there a command that will let me put
new lines of code with the correct indentation?
:nnoremap p p`[v`]=
taken from https://github.com/sickill/vim-pasta.