VIM: replace a character in the middle of line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers VIM: replace a character in the middle of line
# 1  
Old 07-18-2009
VIM: replace a character in the middle of line

exmaple, i need to replace the number "5" from all lines below with "X"?
What is the useful vim command that i can apply for..

ddpadsgg506xghssuyj
ddpadsgag546xghssuys
ddsadsgaag596xghssuy_te
ddsadsgag506xghssuy_pe
ddsadsgagc526xghssuys
ddsads506ighssuys
ddsadsgag506pghssuyk
# 2  
Old 07-19-2009
Code:
:1,$s/5/X/

this is the same question you asked here
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace x-y character in line

I have a file which has n number of lines, i want to replace 3rd line position 3-5 to some text. 111111111111111111 222222222222222222 333333333333333333 444444444444444444 expected output 111111111111111111 222222222222222222 33abc3333333333333 444444444444444444 it is... (7 Replies)
Discussion started by: greenworld123
7 Replies

2. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

3. UNIX for Dummies Questions & Answers

VIM search and replace with line breaks in both the target and replacement text

Hi, Ive spent ages trying to find an explanation for how to do this on the web, but now feel like I'm :wall: I would like to change each occurence (there are many within my script) of the following: to in Vim. I know how to search and replace when it is just single lines... (2 Replies)
Discussion started by: blueade7
2 Replies

4. Solaris

Line too long error Replace string with new line line character

I get a file which has all its content in a single row. The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file. I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies

5. Shell Programming and Scripting

Replace last character of every second line

Hi all. I wonder if this possible.... any help advice is very much appreciated.. I n a shell script I create a latex file that looks like this \documentclass{article} \usepackage{graphics} \begin{document} \begin{figure} \begin{center} \begin{tabular}{cc} ... (10 Replies)
Discussion started by: malandisa
10 Replies

6. Shell Programming and Scripting

how to replace character in the line

I have unix text file which has the following data aadjdfad;fa;fjjd;lakd;lkaslkd;k;k;lk;k;lk;l;lk;lkj;lj;lkj;k;lkj;lj;lkj;lkj;lkj;j sdkadk;adlf;lajf;akdjf;lkdjf;lkadjf;lkajsd;lfkj;lkj;lkj;lk;lk;lk;lk;k;lkj;k;lkm... (2 Replies)
Discussion started by: Raju Datla
2 Replies

7. Shell Programming and Scripting

replace > with new line character

<reward_data><date><datetime>071308000804</datetime></date> I want the above data to be displayed as <reward_data> <date> <datetime>071308000804</datetime> </date> How can i accomplish this. I tried the below tr "><" ">\n" < filename (4 Replies)
Discussion started by: borncrazy
4 Replies

8. Shell Programming and Scripting

Replace certain character with a new a new line.

Hello all... please help with the following. I am parsing the following type of file... W001; W003; W025;W044; W030; W022;W024;W099;W098; Would like to make it look like this... W001 W003 W025 W044 W030 W022 W024 W099 W098 (8 Replies)
Discussion started by: djsal
8 Replies

9. Shell Programming and Scripting

to replace a new line character

sample I/p: S12J LLL H77K PPP J25O LOP I73S lOP K99O PLO Required O/p: S12J LLL H77K PPP J25O LOP I73S lOP K99O PLO how to replace a new line character with space using sed command only Cheers, Chan (2 Replies)
Discussion started by: chan
2 Replies

10. Shell Programming and Scripting

awk insert character in the middle of a line

I'm trying to insert a single character at position 11 in everyline of a file. My input file looks like this: 456781 ~Y~12345 456782 ~N~12300 and I want my output to look like this: 45678~1 ~Y~12345 45678~2 ~N~12300 I tried the following awk code, but it's not working:... (3 Replies)
Discussion started by: mmarino
3 Replies
Login or Register to Ask a Question