When editing C++ files and when inserting new lines above or below a

comment (//) line, Vim automatically inserts the C++ comment character (//) at the beginning of the line. How do I disable this? This automatic insertion of the comment leader (//) when new lines are added is controlled by three flags in the ‘formatoptions’ option: ‘c’, ‘r’ and ‘o’. ‘c’ enables auto-wrapping of comment lines when typing extends beyond the right margin. ‘r’ enables the automatic insertion of the comment leader when <Enter> is pressed while editing a comment line. ‘o’ enables the automatic insertion of the comment leader when a new line is opened above or below an existing comment line by typing O or o in Normal mode. You can stop Vim from automatically inserting the comment leader when typing <Enter> within a comment or when opening a new line by removing the ‘r’ and ‘o’ flags from ‘formatoptions’. :set formatoptions-=r :set formatoptions-=o The default filetype plugin for C and C++ files ($VIMRUNTIME/ftplugin/c.vim) adds the ‘r’ and ‘o’ flags to the ‘formatoptions’ option. If you want to override this for C++ files, then you can add the above lines to the ~/.vim/after/ftplugin/cpp.vim file.

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind