Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vi visual mode action on section

Posted on 2004-04-25
4
Medium Priority
?
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

730 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