Vim logo vim online Vim Book Ad

basic Tip #350: when 'formatoptions' has o easily enter a non commented line: go/gO mappings

 tip karma   Rating 1/3, Viewed by 270 

created:   October 24, 2002 2:13      complexity:   basic
author:   Feral of firetop dot com      as of Vim:   5.7

This is relevant when your 'formatoptions' has o.
From :h fo-table, "Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode."
I like this behavior enough to keep the o option, however at times I want to NOT insert the comment chars, and although manually deleting the added chars is not hard I present these simple mappings that delete the added chars automatically.

(from my .vimrc)
nnoremap go o<esc>S
nnoremap gO O<esc>S

This makes go open a new line under the cursor and removes inserted chars, while gO opens a new line above the cursor and removes inserted chars.

Your mileage will vary of course (:
Happy VIMing!

 rate this tip  Life Changing Helpful Unfulfilling 

<<Format your xml document using xmllint | Using quickfix in a different way >>

Additional Notes

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo