(Change <tt> to <code>, perhaps also minor tweak.)
Line 4:
Line 4:
|previous=349
|previous=349
|next=351
|next=351
−
|created=October 24, 2002
+
|created=2002
|complexity=basic
|complexity=basic
|author=Feral
|author=Feral
Line 12:
Line 12:
|category2=
|category2=
}}
}}
−
This is relevant when your <tt>'formatoptions'</tt> includes <tt>o</tt>.
+
This is relevant when your <code>'formatoptions'</code> includes <code>o</code>.
From {{help|fo-table}}, "Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode."
From {{help|fo-table}}, "Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode."
−
I like this behavior enough to keep the <tt>o</tt> 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.
+
I like this behavior enough to keep the <code>o</code> 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.
<pre>
<pre>
Line 26:
Line 26:
==Comments==
==Comments==
−
It should be noted that the <tt>go</tt> mapping presented above will interfere with Vim's default <tt>go</tt> (Go to {count} byte in the buffer {{help|go}}) command.
+
It should be noted that the <code>go</code> mapping presented above will interfere with Vim's default <code>go</code> (Go to {count} byte in the buffer {{help|go}}) command.
There should be a much more elegant way of achieving the same effect, but I am currently unaware of what it might be.
There should be a much more elegant way of achieving the same effect, but I am currently unaware of what it might be.
Latest revision as of 05:25, July 13, 2012
Please review this tip:
This tip was imported from vim.org and needs general review.
created 2002 · complexity basic · author Feral · version 5.7
This is relevant when your 'formatoptions' includes o.
From :help 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.
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.