LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-20-2005, 09:01 PM   #1
racarter
LQ Newbie
 
Registered: May 2005
Distribution: Debian 3.1 and others
Posts: 3

Rep: Reputation: 0
Question about using vi


I have a need to replace all occurrences of a blank space with a new line in a text file. I think this is something vi could do (I looked it up and the command should be something like %s/dog/cat/g where dog is to be replaced by cat) but the thing is that I don't know how to represent a newline character. Any advice?
 
Old 07-20-2005, 09:14 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
\newline
should represent it
 
Old 07-20-2005, 09:27 PM   #3
twsnnva
Member
 
Registered: Oct 2003
Location: Newport News, Va
Distribution: Debian
Posts: 246

Rep: Reputation: 30
%s/ /^M/g is what you want to do. You get the ^M by pressing ctrl+v then crtl+m.
 
Old 07-20-2005, 09:28 PM   #4
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
try this:
Code:
%s/ /\n/g
newline=\n
tab=\t
 
Old 07-20-2005, 09:40 PM   #5
twsnnva
Member
 
Registered: Oct 2003
Location: Newport News, Va
Distribution: Debian
Posts: 246

Rep: Reputation: 30
In vi:
newline character = ^M (ctrl+v then ctrl+m)
tab character = ^I (ctrl+v then ctrl+i)
 
Old 07-20-2005, 10:20 PM   #6
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Quote:
Originally posted by twsnnva
In vi:
newline character = ^M (ctrl+v then ctrl+m)
tab character = ^I (ctrl+v then ctrl+i)
\n also works (at least for me in elvis, the default vi-clone in slackware)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
2 part question: Speeding up MDK9.1/GNOME question wardialer Linux - Newbie 6 10-14-2004 03:16 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration