Difference between revisions of "Disabling auto-comment of next line in vim"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb> =Disabling auto-comment of next line in vim= Sometimes while editing a known file type with vim it automatically continues the co...")
 
m
Line 22: Line 22:
</pre>
</pre>


Steps have been learned from http://vim.wikia.com/wiki/Disable_automatic_comment_insertion


Steps have been learned from http://vim.wikia.com/wiki/Disable_automatic_comment_insertion
 
 
=Disabling auto-indent in vim=
 
If the above technique is not working for disabling auto-indentation then use:
<pre>
:setl noai nocin nosi inde=
</pre>
Steps learned from http://vim.wikia.com/wiki/How_to_stop_auto_indenting




<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>
<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>

Revision as of 11:38, 18 May 2015

<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>

Disabling auto-comment of next line in vim

Sometimes while editing a known file type with vim it automatically continues the comment on next line. For example if one has line '//abc' in a C file then pressing return key at the end of this line would cause next line to automatically have comment characters '//'. The same is applicable while editing .emacs file with vim where comments begin with ';'.

Now if we copy paste some C program lines or .emacs configuration lines from other location into the current file then this automatic extension of comment causes problem as all lines after first comment line get commented while pasting. Thus to disable this auto-comment feature while pasting lines from other source one can modify formatoptions variable.

To see current value of formatoptions variable use:

:set formatoptions?

To disable auto-comment extension by modifying formatoptions use:

setlocal formatoptions-=c formatoptions-=r formatoptions-=o


To disable comment extension permanently for few types of files one can use following configuration in .vimrc file:

autocmd FileType c,cpp setlocal formatoptions-=c formatoptions-=r formatoptions-=o

Steps have been learned from http://vim.wikia.com/wiki/Disable_automatic_comment_insertion


Disabling auto-indent in vim

If the above technique is not working for disabling auto-indentation then use:

:setl noai nocin nosi inde=

Steps learned from http://vim.wikia.com/wiki/How_to_stop_auto_indenting


<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>