LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Blogs > xri
User Name
Password

Notices



Rate this Entry

How to replace letters with carriage returns on VIM

Posted 10-27-2010 at 01:35 PM by xri
Updated 10-27-2010 at 01:38 PM by xri (To add categories)

Problem:
A text file coms with a list comes with the items separated by commas, like:
Quote:
a,b,c....
We need them in column form, like:
Quote:
a
b
c
Solution:
:%s/,/{[Ctrl+v], then [Enter]}/g

Notes:
  1. The % before s, indicates that the range where the replacement is to take place is the whole document.
  2. Ctrl and v are pressed simultaneously, and then the character we mean vim to use (in this case Return).
  3. The g at the end of the expression indicates that every occurrence on the line where the comma is found is to be replaced (as opposed to only the first occurrence).
Posted in Software
Views 1022 Comments 0
« Prev     Main     Next »

  



All times are GMT -5. The time now is 10:17 PM.

Main Menu
Advertisement

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