LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 08-16-2007, 05:21 PM   #1
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
VI replacement: newline for newline not working!


I was trying to match end of lines, and do a replacement:

Code:
: % s/\n/<\/li>\n/g
to add a </li> to the end of a every line in an unordered list in an html document.

However, the '\n' that is substitutded is not right!

To prove this to myself, I tried:

Code:
: % s/\n/\n/g
and sure enough, every '\n' that is found is replaced by what looks like a ^@ in vi, as opposed to just staying the same!! What is going on?
 
Old 08-16-2007, 05:38 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
not sure, but the right way to match eol is

:% s/$/<\/li>/g

-- Oh, and you can do

:% s,$,</li>,g

to avoid the need to escape the slash.

Last edited by slakmagik; 08-16-2007 at 05:40 PM. Reason: separator can be anything
 
Old 08-16-2007, 05:46 PM   #3
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
'ga' shows the character to be nul and there's some help under ':h NL-used' and the next section. Though this is for vim.

Last edited by slakmagik; 08-16-2007 at 05:49 PM. Reason: vi != vim
 
Old 08-16-2007, 07:11 PM   #4
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Original Poster
Rep: Reputation: 208Reputation: 208Reputation: 208
Thank you digiot!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Newline in bash Srinivas B T Linux - General 2 06-11-2007 06:14 AM
c++ file IO without newline? PatrickNew Programming 3 12-31-2006 04:24 PM
php + newline??? blizunt7 Programming 1 06-20-2005 12:44 AM
Removing newline. Tarts Programming 2 10-16-2003 12:49 PM
What is a newline? raptorsoft2000 Linux - Newbie 6 08-04-2003 11:05 PM


All times are GMT -5. The time now is 10:17 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration