I would like to add a new line in a certain line in a buffer. So far my starting position is as follows:
let newl = "\n" " set cursor to beginning of buffer call cursor(1,1) " search up to 10 lines down search("somestring",'',10) " get the line number of the match let cursor_pos = getpos(".") let cursor_line = cursor_pos " put a newline directly behind it (cursor_line+1)put =newl
Now, I cannot combine a variable with
put like I would with a number:
11put. How can I accomplish that?
The second problem is rather of a aesthetic nature: When using something like
11put ="\n" Vim behaves weird, it somehow prints out a value of a variable that has nothing to do with a newline.
Is there a way to get the task done in an overall better way - putting a newline at a certain position?