Re: How to comment a line in vim?
Hi, Am Freitag, 02. Jun 2006, 22:27:42 +0800 schrieb Eric Luo: I want to comment a new line or comment an existing line at the end of the current line. In Emacs, I have M-; to do the job. Could anyone tell me that weather the similar functionality existed? Something like this: :noremap F2 Aspacec-r=printf(commentstring,\r)crc-o0$esc-$Jcf$space I don't know how to map it to Alt-;. If you're lucky, the filetype plugin did set the 'commentstring' option correctly. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de
How to comment a line in vim?
I want to comment a new line or comment an existing line at the end of the current line. In Emacs, I have M-; to do the job. Could anyone tell me that weather the similar functionality existed?
Re: How to comment a line in vim?
Eric Luo wrote: I want to comment a new line or comment an existing line at the end of the current line. In Emacs, I have M-; to do the job. Could anyone tell me that weather the similar functionality existed? A line starting with (zero or more whitespace and) a double quote is, in a Vim script, a comment. A comment can also be added after most (but not all) commands by adding a double quote and text on the same line. The problem is that some commands will regard the double quote and what follows it as part of their arguments. In that case you can either move the comment to another line, or wrap the command in an :execute statement followed by a bar and the comment: This is a comment set nobackup writebackup Here we set the backup options exe ! ls | here is how to add a comment on the line of an external command See :help :quote :help :bar :help :execute Best regards, Tony.
Re: How to comment a line in vim?
Eric Luo wrote: I want to comment a new line or comment an existing line at the end of the current line. In Emacs, I have M-; to do the job. Could anyone tell me that weather the similar functionality existed? I have no idea what emacs does, and I suspect that there's quite a few folks who use Vim have no idea, either. In the vein of give a man a fish, feed him once; teach a man to fish, feed him forever: do a search at http://vim.sf.net/ for comment. Perhaps one of the plugins there will address your wishes -- I got 84 hits when I just did it. Regards, Chip Campbell
Re: How to comment a line in vim?
With about the same amount of keystrokes you could use : a \t ; a - for append to end of line then tab then whatever comment character you want. If you record this to a macro you can use @ [char] to add the comment char to the end of any line no matter where you are in the line. Kevin On Jun 2, 2006, at 2:57 PM, Charles E Campbell Jr wrote: Eric Luo wrote: I want to comment a new line or comment an existing line at the end of the current line. In Emacs, I have M-; to do the job. Could anyone tell me that weather the similar functionality existed? I have no idea what emacs does, and I suspect that there's quite a few folks who use Vim have no idea, either. In the vein of give a man a fish, feed him once; teach a man to fish, feed him forever: do a search at http://vim.sf.net/ for comment. Perhaps one of the plugins there will address your wishes -- I got 84 hits when I just did it. Regards, Chip Campbell