DEV Community

Kaziu
Kaziu

Posted on

โ˜˜ How to replace from "new line" to "; new line" on Mac vim

๐Ÿ’Ž Before

I resolved character corruption problem in previous article, but still couldn't execute .sql file!

Why?

";" was not existed in this file

INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(1,'2010/07/23 12:19:45','ono1','shinichi1','1-a-1','ๅ‚™่€ƒAAAAAA1') //* here I need to add ";" !!
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(2,'2010/07/23 12:20:45','ono2','shinichi2','1-a-2','ๅ‚™่€ƒAAAAAA2')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(3,'2010/07/23 12:21:45','ono3','shinichi3','1-a-3','ๅ‚™่€ƒAAAAAA3')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(4,'2010/07/23 12:22:45','ono4','shinichi4','1-a-4','ๅ‚™่€ƒAAAAAA4')
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’Ž How to solve it?

โ–ผ Execute this command on vim

$ %s/ยฅn/;^M/
(^M โ† ctrl+v and Enter)
Enter fullscreen mode Exit fullscreen mode
command Explanation
%s whole file
ยฅn replace ยฅn(new line)
;^M to ;ยฅn (; and new line)

๐Ÿ’Ž After

INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(1,'2010/07/23 12:19:45','ono1','shinichi1','1-a-1','ๅ‚™่€ƒAAAAAA1');
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(2,'2010/07/23 12:20:45','ono2','shinichi2','1-a-2','ๅ‚™่€ƒAAAAAA2');
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(3,'2010/07/23 12:21:45','ono3','shinichi3','1-a-3','ๅ‚™่€ƒAAAAAA3');
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(4,'2010/07/23 12:22:45','ono4','shinichi4','1-a-4','ๅ‚™่€ƒAAAAAA4');
Enter fullscreen mode Exit fullscreen mode

Top comments (0)