Solved

vi visual mode action on section

Posted on 2004-04-25
4
669 Views
Last Modified: 2013-12-15
hi, I can use visual mode okay, and I can also use the familiar
:.,34s/^/#
to comment out perl sections, but
I can't use visual mode to achieve the same effect.   I would like to, because then I could select the section and perform actions on it without using line numbers or anything fancy.

alternatively, can a brave soul volunteer to enlighten me as to how I can use the same effect by going to the } which corresponds to the final { on my line.  In other words, that matches the function body.
0
Comment
Question by:joesp
  • 2
4 Comments
 
LVL 7

Expert Comment

by:glassd
ID: 10916409
% matches any (,{,[ character. Place the curser on one end of the block, hit % and you will be taken to its mate, % again goes back.
0
 
LVL 3

Expert Comment

by:mac_
ID: 10946705
- go to the beginning of the block you want to comment out
- hit v (enter Visual)
- go to the end of the block
- do ':s/^/#<CR>'

-> job done
0
 
LVL 1

Author Comment

by:joesp
ID: 10949844
mac_
that makes no substitution but does manage to highlight the first character of the entire file
:(
I know there's a command that is supposed to operate on the visual section. This command is
'<,'>
which is a range of address from beginning to end of the pattern space.
However, doing
:'<,'>s^/#
too does nothing.
I think it has something to do with using the visual range specifiers but i don't understand how to achieve what I want yet using them.
0
 
LVL 3

Accepted Solution

by:
mac_ earned 50 total points
ID: 10950135
well, it definitely works on quite a few versions of vim (for example my Debian's VIM - Vi IMproved 6.2 (2003 Jun 1, compiled Apr  1 2004 23:39:33))

the ':s/^/#<CR>' sequence is what you have to TYPE, '<,'> will be added by VI (meaning "Range is current selection")... and please check again the sequence :

:s/^/#<CR> vs s^/# you wrote... you're missing a few /'s

(you obvisouly have to select at least one beginning of line).

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now