Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding comma to each line using sublime text 2

I am trying to use sublime's text search and replace function and regex to match a string of number in each line and append a comma to each. So here's the sample file:

 273794103  418892296  134582886  380758661  109829186  248050497  2167935715  374858669 

I want this to be:

 273794103,  418892296,  134582886,  380758661,  109829186,  248050497,  2167935715,  374858669, 

I tried doing this (\d+)\n and replacing it with $1, but this doesn't work. Any idea why? FYI for those who are not into sublime but into regex, Sublime Text uses Python's regex engine.

like image 923
adit Avatar asked Nov 03 '13 06:11

adit


People also ask

How do you put a comma after every line in Vscode?

Select all by pressing CTRL+A (or Command+A for Mac). From Selection, choose Add Cursors to Line Ends by pressing SHIFT+ALT+I (or SHIFT+OPTION+I). Type the Comma character.


2 Answers

To add comma to any line

  1. Select the lines you want to modify

  2. CTRL + SHIFT + L

  3. RIGHT_ARROW

  4. COMMA

Using ctrl + shift + L is how you can modify all selected lines. Very handy :-)

like image 78
John Foley Avatar answered Oct 10 '22 06:10

John Foley


I'd recommend this

'Find What': $ // matching all ends of your lines
'Replace With': , // replaces all line ends with a coma

this will work with any file :-)

like image 26
bukart Avatar answered Oct 10 '22 07:10

bukart