![]() ![]() I prefer only to have a 'toggle' style function. I added a mapping to normal and visual modes, but you can remap to anything you like. You simply add a new filetype to the comment_map and its comment leader. vimrc file which works pretty well and can be extended easily. ![]() I've come up with a simple addition to my. (Thanks to and for improvements incorporated into this answer) Note 3: Bare-bones vim sometimes doesn't have the norm command compiled into it, so be sure to use the beefed up version, ie typically /usr/bin/vim, not /bin/vi Eg putting the following line in ~/.vimrc lets you type ctrl-n instead of :norm after making your visual selection vnoremap :norm ![]() Note 2: You could of course also add a mapping if you find yourself using norm a lot. If you need the escape character as part of your command sequence, type ctrl-v then hit the escape key (or even easier, just record a quick macro and then use norm to execute that macro on each line). Note: Since norm is literally just executing regular vim commands, you're not limited to comments, you could also do some complex editing to each line. Note that unlike block selection, this technique works even if the comments have uneven indentation! will produce a very quick countdown from 3 to Blast Off as the lines disp (2) and disp (1) wont be executed. Which means "go to the first non-space character, then delete one character". If the comments are indented as in the OP's question, then you can anchor your deletion like this: :norm ^x If I had used a 2-char comment such as // then I'd simply do :norm xx to delete both chars. This deletes the first character of each line. visually select the text as before (or type gv to re-select the previous selection) Note that when you type : the range will be filled in, so it will really look like :'norm i# This inserts "#" at the start of each line. visually select the text rows (using V as usual) In these cases a low-tech alternative is the built-in norm command, which just runs any arbitrary vim commands at each line in your specified range. vimrc cannot help me, or sometimes NerdCommenter gets it wrong (eg JavaScript embedded inside HTML). 2.1) We can comment multiple lines using Ctrl+/ We can uncomment multiple lines using Ctrl+ View the full answer. Sometimes I'm shelled into a remote box where my plugins and. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |