Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Vi editor question


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Vi editor question

in Vi how do I delete part of a line ( leave few words in a line and delete rest of the line )
# 2  
Hmm. I use "dw" (delete word ) repeatedly to remove chunks of text. If someone else has a better choice I'd like to know, too.
yank does one or more whole lines, so it won't work.

You can use "d $" to delete from the current cursor position to the end of the line. AFAIK there is no way to remove a chunk of text from the middle of the line, except with X,x, or dw

See the vi cheat sheet:
Vi Cheat Sheet
# 3  
It accepts numbers before as well.
e.g. 3dw will delete 3 words in line from cursor to the right.

Regards
Peasant.
# 4  
Use D in command mode. It deletes the rest of the line from the cursor position.
Command C does the same but then switches to insert mode after deleting rest of the line so that you can start editing the line.
# 5  
Hi.

In command mode d$ deletes to end-of-line, d0 deletes to beginning of line.

They are not quite symmetrical, d$ deletes the character under the cursor, d0 does not, but my fingers got used to the difference ... cheers, drl
This User Gave Thanks to drl For This Post:
# 6  
Last tip: as you already have been told "D" in command mode deletes from the cursor position to the end of line. To effectively put the cursor to the correct position you can use the "w" command, which moves you to the start character of the next word or "W" to put you to the start character of the next word separated by blanks. The difference is that some characters (i.e. ":", "-", etc.) are also recognized as word boundaries and in a line like this:

Code:
abc+def:ghi jkl-mno pqr

if you are at the first character, entering "w" consecutively will put you over the "+", the "d", the ":", the "g" etc.. Entering "W" instead will put you on the "j" first and the "p" next.

You can also use multipliers for these commands, so "4w" on the first character of the line will put you on the "g" immediately.

I hope this helps.

bakunin
# 7  
Without a better explanation of what you're trying to do, it is hard to give a good answer.

If you want to delete all but the last 3 words on every line, or delete the first 2 words on every line, we can make suggestions that will help. If you want to delete everything but a few recognized words (and can't or won't tell us which words are "recognized"), it becomes much harder for us to make any useful suggestions.

If you can show us a representative sample input file and explain how you want to modify that text and show us the output you hope to produce, we can do a much better job of making useful suggestions.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Message Editor question
Andre_Merzky
Hia, this is a very low priority request, but I am slightly annoyed by the behaviour of the tags in the message editor. They behave assymetric in the sense that the opening tag is introducing an empty line, and the closing tag is not, and can't be convinced to do otherwise. I know I am...... Post Here to Contact Site Administrators and Moderators
1
Post Here to Contact Site Administrators and Moderators
vi editor question
MeetP
This is an vi editor question. I do not know is this a right place to ask this question or not? I have a file with the following contents, 10 11 20 21 30 31 I want to copy first column that is 10,20,30 after second column, so that output will look like the following, 10 11 10 20 21...... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
vi editor question
Katkota
Folks; I know this may sound stupid, but when i use vi to edit in SUSE, i see the file has a lot of underlines, how can i get rid of underline permanently so when i open any file to edit, i don't see any underlines? Thanks in advance... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers
vi editor question
mgb
Hi, How do you delete from where ever you are to the bottom of the page. I'm pretty sure it was a simple command but can't pull it out of memory. Thanks, mgb... UNIX for Dummies Questions & Answers
4
UNIX for Dummies Questions & Answers
VI Editor question
BG_JrAdmin
When I use vi, I can type "set nu" in command mode to get line numbers. How can I get VI to start like that automatically?... UNIX for Dummies Questions & Answers
2
UNIX for Dummies Questions & Answers

Featured Tech Videos