(Replace category 'C plus plus' with 'C++') |
Carpetsmoker (talk | contribs) ({{dodgy|Looks useful, but it does not work}}) |
||
Line 1: | Line 1: | ||
+ | {{dodgy|Looks useful, but it does not work}} |
||
+ | |||
{{review}} |
{{review}} |
||
{{TipImported |
{{TipImported |
Revision as of 00:42, 17 April 2008
Tip 35 Printable Monobook Previous Next
created March 7, 2001 · complexity intermediate · author slimzhao · version 5.7
With the following mappings, you can press \c to change all C++ comments to C comments, or press \C to change all C comments to C++ comments (assuming you are using backslash for your <leader> key).
Note: The mappings only handle single-line C comments.
For example, if you press \c then the following C++ code:
int i = 12; // this is a comment char c = 'A'; // and here is another comment
changes to use C comments:
int i = 12; /* this is a comment */ char c = 'A'; /* and here is another comment */
Here are the mappings. You could put these in your vimrc:
" C++ //-comment to C /*-comment-*/ :noremap <leader>c :%s://\(.*\):/*\1 */:<CR> " C /*-single-line-*/ to C++ //-comment :noremap <leader>C :%s:/\*\(.\{-\}\)\s*\*/://\1:<CR>