Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not sure of some unix commands in VI

Status
Not open for further replies.

alku83

Technical User
Apr 5, 2001
4
AU
Hi,
I am trying to do a Uni assignment on Unix, and I'm not quite sure of some of the questions, I was hoping I could get some help?
Thanks, here are the questions, and what i *think* the answers are:

Q1: Describe an efficient way to remove all trailing blanks (SPACE and TAB) at the end of all lines

A: somethign to do with $


Q2: How would you change all instances of multiple consecutive spaces to single space

A: :g/ /s// /g


Q3: How do you search for a word without regard to upper or lower case

A: :set ic
/'word'


Q4: Find out vi definitions for sentence, paragraph, and section, as related to the commands ), (, }, and ]], [[

A: ??


Q5: Suppose you want to search for the character ^M (RETURN) just before the end of any line. How would you tell VI to search for this? How would you delete all such patterns in your VI buffer with one global replace command?

A: ??

Thanks a lot
 
Hi,
For the last one ( ^M question ),
use
col -bx <filename >
to remove all sucn ^Ms.
&quot;col&quot; is not a VI command but its a seperate command.
COL outputs in the STD op which ofcourse u can redirect
into someother file..Dont redirect into the same file,
u will lose everything.
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
In vi, you can remove all ^M characters with the command

:%s/^V^M//g

When entering a pattern, if you enter ^V, that tells vi to expect a control character next.

Greg.
 

Hi, alku83!

To change all instances of multiple consecutive spaces to single space, you can try this search command:

%s/ .* / /gc

Be careful when entering a pattern: space, period, asterisk and space.

Bye!

KP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top