Solved

vi visual mode action on section

Posted on 2004-04-25
4
676 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 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

738 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