LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-03-2006, 06:35 AM   #1
gandi71
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
how to replace numbers in vi ?


i have to change all numbers in the text in vi like this xxx.xxx --> xxx,xxx

how to do it in one-line command ?
 
Old 04-03-2006, 06:44 AM   #2
Pavan mahoorker
LQ Newbie
 
Registered: Sep 2004
Location: Bangalore
Posts: 7

Rep: Reputation: 0
Hi,
First come out of your insert or append mode in vi by presseing the Esc button then type as below.
:%s/xxx.xxx/xxx,xxx the enter key
And if you want to replace every where then use :%s/xxx.xxx/xxx,xxx/g
 
Old 04-03-2006, 04:42 PM   #3
gandi71
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
advanced regular expression in vi

thanks, but it's not satisfactionary (?!) answer, because I have to replace only these dots which are neighbours of the numbers.

for example : '12.45' should be replaced to '12,45' , '26.3' to '26,3' etc. ; but the result of 'linux.com' should not be 'linux,com' ! (no changes in this example !)

I have to use an advanced regular expression, but I don't know how
 
Old 04-03-2006, 04:49 PM   #4
linuxChique
LQ Newbie
 
Registered: Apr 2003
Location: Huntsville, AL
Distribution: mandrake
Posts: 4

Rep: Reputation: 0
use something like:

Code:
:%s/\(\d\)\.\(\d\)/\1\,\2/g
 
Old 04-03-2006, 05:31 PM   #5
gandi71
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
it's really works !

thanks for you , 2 points for me
 
  


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
Even numbers paraiso Linux - Newbie 4 05-15-2005 04:31 PM
what do the numbers mean? drisay Slackware 1 12-14-2004 08:30 AM
54 digit numbers Scratchit General 3 06-23-2004 10:24 AM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 10:18 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 02:04 AM

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

All times are GMT -5. The time now is 06:47 PM.

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