Reformatting With Vim

Profile
by Jess Brown

If you're using markdown a lot with vim, you may have run into an issue with formatting. After you type a paragraph, then go back to edit, the auto softwrap that happens, gets off when you add or delete text.

This used to drive me nuts, until I found a simple fix. gq will reformat the line and reset the wrapping. Most of the time, you'll need to fix the whole paragraph because any edits typically effect lines and words afterwards as well. So, you can select the whole paragraph and reformat with vipgq.

I ended up mapping this to a shortcut:

# .vimrc
map <leader>al vipgq

Subscribe to our mailing list


comments powered by Disqus