Solved

vi editor command - delete a column.

Posted on 2015-02-20
4
306 Views
Last Modified: 2015-02-20
I know vi relatively well.

dd - deletes a line
5 dd - deletes 5 lines.

How do you delete a singe character column? ...or  5 character columns, all the way to the bottom of the vi document?
0
Comment
Question by:Rambl
  • 2
4 Comments
 
LVL 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen earned 250 total points
ID: 40621416
You can use the block mode of vi, use <ctrl>-v to enter that mode, select text by moving cursor (to the right). Use G to go to end of the file and press d to delete your column. Leave block mode using <esc>
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 250 total points
ID: 40621429
As far as I know, vi cannot do that, but vim can.
In most Linux'es "vi" is in fact "vim".

- Position the cursor at the start column and hit <Ctrl><v>
- Move the cursor to the end column. The block will be highlighted.
- Move the cursor down to mark a rectangle to operate upon.
EDIT: "G" does not work here (at least not for me) because it jumps to the first column of the last line.
- Hit the key corresponding to the desired action, e. g. "d" for delete.

The above is called "visual block mode" in vim.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 40621463
vim - yes, the default 'vi' on most Linux systems.

@Rambi: if you do "vi --version", do you see something like:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 10 2013 03:57:45)
...

If that's so then you have vim (with an alias named vi) and you can use the visual mode.
0
 

Author Closing Comment

by:Rambl
ID: 40621494
which vi
/bin/vi

which vim
usr/bin/vim

-rwxr-xr-x  1 root root  629032 Jul 10  2012 vi
-rwxr-xr-x  1 root root    2828960 Jul 10  2012 vim

when I run vi, it doesn't allow me to do a ctrl-v (visual block)
when I run vim, it does

what's odd, is if I run:
/usr/bin/vim --version
/bin/vi --version

They seem to be the same version.

Perhaps vi is using the same config files the vim is using, but it still functions like the old vi. Maybe it's running "vim" in some kind of "vi" mode.

I just thought that was interesting.

Anyway, thanks for the help. ctrl-v in vim accomplished what I wanted.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
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.

911 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

25 Experts available now in Live!

Get 1:1 Help Now