Solved

vi visual mode action on section

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
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.

708 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

16 Experts available now in Live!

Get 1:1 Help Now