I'm using Notepad++ and I can't figure this out :
I have numerous lines all starting with http
. I need to add some text in front of it in every line. Also, I need to add different text to the end of each line. Each line ends differently.
What is the fastest way to add text to the start and end of each line?
This question is related to
notepad++
Follow these steps:
Regular expression
option near the bottom of the dialog.To add a word, such as test
, at the beginning of each line:
- Type
^
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
To add a word, such as test
, at the end of each line:
- Type
$
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
Notepad++ Add Word To Start Of Every Line
Follow this instruction to write anything at the start of every line with Notepad++
Open Notepad++,
Press Cntrl+H open the Find/Replace Dialog.
Now type ^ in the Find what textbox (Type ^ without any spaces)
Type anything(like in our example I am writing "John ") in the Replace with textbox (Write text one/more space for adding one/more space after your text in every line)
Select the Regular Expression option
Place your cursor in the first line of your file to ensure all lines are affected
Click Replace All button
Notepad++ Add Text To End Of Every Line
Follow this instruction to write anything at the end of every line with Notepad++
Open Notepad++,
Press Cntrl+H open the Find/Replace Dialog.
Now type $ in the Find what textbox (Type $ without any spaces)
Type anything(like in our example I am writing " John") in the Replace with textbox (Write one/more space text for adding one/more space before your text in every line)
Select the Regular Expression option
Place your cursor in the first line of your file to ensure all lines are affected
Click Replace All button
For all Notepadd++ Tutorials: VISIT:)
If you have thousands of lines, I guess the easiest way is like this:
-select the line that is the start point for your cursor
-while you are holding alt + shift select the line that is endpoint for your cursor
That's it. Now you have a giant cursor. You can write anything to all of these lines.
In order to do it in one go:
http:\blahblah.com
http:\blahnotblah.com
http:\blahandgainblah.com
^(.+)$
. Here ^ represents the start of the line. $ represents the end of the line. (.+) means any character in between the start and the end of the line and it would be group 1.WhateverFrontText(\1)WhatEverEndText
. Here (\1) means whatever text in a line.WhateverFrontTexthttp:\blahblah.comWhatEverEndText
WhateverFrontTexthttp:\blahnotblah.comWhatEverEndText
WhateverFrontTexthttp:\blahandgainblah.comWhatEverEndText
Notepad++ has a very powerful editing capability. (Today I'm searching for the similar function in Sublime Text), but for Notepad++, just hold Alt when you drag the mouse. What you type will then replace the selected column on every line. To insert without replacing existing text, use Alt-Shift.
To append different text to the end of each line, you can use the plugin ConyEdit to do this.
With ConyEdit running in the background, follow these steps.
cc.gl a
to get lines and store in an array named a. cc.aal //$a
to append after each line, using the contents of array a.Well, I am posting this after such a long time but this will the easiest of all.
To add text at the beginning/a-certain-place-from-start for all lines, just click there and do ALT+C and you will get the below box. Type in your text and click OK and it's done.
To add a certain text at end of all lines, do CTRL+F, and choose REPLACE. You will get the below box. Put in '$' in 'find what' and in 'replace with' type in your text.Make sure you choose 'regular expression' in the search mode (left down). Finally click 'replace all' and you are done.
This allows you to type on every line simultaneously.
I found the solution above here.
I think this is much easier than using regex.
Simply in the "Find what:" field, type \r
. This means "Ends of the Row". In the "Replace with:" field, you put what you want for instance .xml
if you have several lines, and you are aiming to add that text to the end of the each line, you need to markup the option ". matches newline" in the "Search Mode" group box.
Example:
You have a file name list, but you want to add an extension like .xml. This would be what you need to do and Bang! One shot!:
You can automatically do it in Notepad++ (add text at the beginning and/or end of each line) by using one regular expression in Replace (Ctrl+H):
Explanation: Expression $1
in Replace with input denotes all the characters that include the round brackets (.*)
in Find what regular expressin.
Tested, it works.
Hope that helps.
Source: Stackoverflow.com