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.
To add comma to any line
Select the lines you want to modify
CTRL + SHIFT + L
RIGHT_ARROW
COMMA
Using ctrl + shift + L is how you can modify all selected lines. Very handy :-)
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 :-)
Here's how you'd do it on a Mac:
Command+shift +L > Right Arrow > Comma
and Windows/Linux:
Ctrl+Shift +L > Right Arrow > Comma
Replacing .+
with $0,
worked for me
For Window User:
select all line OR select part of line => Ctrl+A.
Bring cursor to last of each Line => Ctrl+Shift+L
Add comma(,) which will reflect to all line.
** If you want to add comma(,) at start of each Line , After step 2 press => Home(button from keyboard , all cursors will head to start of the line)
Finally Ctrl+s to save the changes.
cheers