I'm trying to make a vmap that takes a count and then indents all the highlighted lines so that the top one is more than the line above it, while keeping all the lines' relative indentation. I have made it to this function and I'm experiencing some behaviour I don't know how to figure out. For some reason, this function will only indent the top line of the selection. I've tested it using
echomsg instead of
execute, and then just pasting the commands in explicitly and it works just fine. But for some reason when it's in this for loop, it only executes the first one.
function! Test() let above = line("'<") - 1 for line in range(line("'<"), line("'>")) execute line . "left " . (indent(above) + 4 + indent(line) - indent("'<")) endfor endfunction
Also, if there's a plugin that'll already do this for me, feel free to let me know.
Putting this function at the top of the file, changing
echomsg, highlighting the function body, and then running
:cal Test() give the following ouput
2left 4 3left 0 4left 4 5left 8 6left 4
Which is expected, so I don't understand what's going wrong when I use