Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vi visual mode action on section

Posted on 2004-04-25
4
Medium Priority
?
686 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 200 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

876 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