VIM multi-line inserts making me crazy

Steve Seremeth blu_discuss at seremeth.com
Wed Jun 15 11:17:04 EDT 2005


dsr at tao.merseine.nu wrote:

>On Wed, Jun 15, 2005 at 11:01:47AM -0400, Steve Seremeth wrote:
>  
>
>>I can do search and replace in the block like so:
>><C-V>
>>Use arrows (or "j") to pick your lines
>>:s/^/#/  (which turns into: ":'<,'>s/^/#/")
>><enter>
>>
>>But then vim matches the beginning of every line in the file as noted by 
>>the blinding yellow highlighted line I get up the side of my terminal.  
>>If I wanted to indent using tabs, I would highlight the block and then 
>>use ">" -- and I know I can define tab/space settings in my .vimrc, 
>>etc..  Is that my best option?  That doesn't cover me when I want to 
>>insert comment chars.
>>
>>Am I overlooking something (as I'm guessing I am)?
>>    
>>
>
>If I understand you, you want to be able to add a comment
>character at the beginning of each line. The easiest way
>to do that, IMHO, is:
>
>position your cursor at the starting line
>count how many lines you want to do this to - call it N
>:.,+Ns/^/#/
>
>Or if you have line numbering turned on, you can just say
>:12,42s/^/#/
>to do lines 12 through 42
>
>Is that what you wanted?
>  
>
I guess line numbering will cut it (and is fairly elegant) -- I've never 
used it in the past, but that's no reason not to now.  It would seem 
that there should be some easy way to do this in visual mode 
(confession: my arrow keys are practically worn out from overuse) 
though.  Also no vi. vs emacs flames either, please.  I'm sure there are 
eleventeen ways to do this in emacs.

Steve



More information about the Discuss mailing list