We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

yuconner on 08/21/06


Tagged

linux editor vi


Versions (?)


Easy (un)commenting out of source code with vi editor


Published in: Other 


URL: http://www.vim.org/tips/tip.php?tip_id=271

Put into your .vimrc file

The commands to comment a selection of text are as follows, begining with begining-of-line comments:

,#    shell, perl, etc
,/     c  
,>    email quote
,"     vim
,%    latex, prolog
,!      assembly?... add single !
,;      scheme
,-      don't remember this one... add --
,c     clears any of the previous comments

Here are the wrapping comments, each line wrapped individually:

,*      c
,(       Standard ML
,<      html
,d      clears any of the wrapping comments
  1. #" lhs comments
  2. map ,# :s/^/#/<CR>
  3. map ,/ :s/^/\/\//<CR>
  4. map ,> :s/^/> /<CR>
  5. map ," :s/^/\"/<CR>
  6. map ,% :s/^/%/<CR>
  7. map ,! :s/^/!/<CR>
  8. map ,; :s/^/;/<CR>
  9. map ,- :s/^/--/<CR>
  10. map ,c :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR>
  11.  
  12. #" wrapping comments
  13. map ,* :s/^\(.*\)$/\/\* \1 \*\//<CR>
  14. map ,( :s/^\(.*\)$/\(\* \1 \*\)/<CR>
  15. map ,< :s/^\(.*\)$/<!-- \1 -->/<CR>
  16. map ,d :s/^\([/(]\*\\|<!--\) \(.*\) \(\*[/)]\\|-->\)$/\2/<CR>

Report this snippet 

You need to login to post a comment.