In vim I want to visually make transparent the space I have to write a text in markdown. I use hard wrapping with textwidth=79
. I know by some calculation that I'll have 20 lines for a chapter for example. So, what I do is inserting 20 empty lines to get a visual feeling for what I can write. After writing some lines, I manually delete the number of lines already written from the empty lines, so that the visual impression still is correct.
What I want to do, is to automate this deletion process. That means I want vim to automatically remove one line below the last written line if this line is empty and after vim automatically started a new line because I reached 79 characters in the line before. How can I do this?
I know that there are autocommands in vim but I haven't found an <event>
that fits to the action: after vim automatically hard wraps a line / reached new line in insert (or however you would like to describe it)
I don't think there's an event for that particular action but there's a buffer-local option called formatexpr
that gq
& co will use, if set. So you can write a function that inspects any placeholder whitespace, if existing. That function can call the text format command gqq
to maintain original feel (+ the cursor movement to the new, empty line).