Solved

vi editor command - delete a column.

Posted on 2015-02-20
4
286 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

744 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

14 Experts available now in Live!

Get 1:1 Help Now