In my vimrc I have the following:
vmap Q gw
nmap Q gwap
set formatoptions+=cj
set formatoptions-=t
This disables automatic text wrapping, and allows me to correctly wrap the paragraph my cursor is on right now by pressing Shift+Q.
Normally, formatting a paragraph is exactly what I want to do, but here's an example of where it's wrong:
# This is a long comment in a Python file. It is longer than 80 characters, and should get wrapped.
def a_function():
"""This is still in the same paragraph."""
Now, when I put my cursor on the comment and press Shift+Q, this happens:
# This is a long comment in a Python file. It is longer than 80 characters, and
# should get wrapped.
def a_function(): """This is still in the same paragraph."""
I want the following to happen:
# This is a long comment in a Python file. It is longer than 80 characters, and
# should get wrapped.
def a_function():
"""This is still in the same paragraph."""
Is there a combination of commands or a plugin that does this? I want to use the same key to wrap regular text and comments, and use paragraphs for text, but when my cursor is on a comment I want the wrapping to be limited to the comment.
gqq
there or possibly some variation ofgqj
orgq2j
– sehe Dec 17 '15 at 17:01