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?
end of line
(I do not recall which symbol it is) with [myText]end of line
Follow these steps:
Press Ctrl+H to bring up the Find/Replace Dialog. Choose the Regular expression option near the bottom of the dialog.
To add a word, such as test
, at the beginning of each line:
Type ^ in the Find what textbox Type test in the Replace 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 the Find what textbox Type test in the Replace with textbox Place cursor in the first line of the file to ensure all lines are affected Click Replace All button
Move your cursor to the start of the first line Hold down Alt + Shift and use the cursor down key to extend the selection to the end of the block
This allows you to type on every line simultaneously.
I found the solution above here.
I think this is much easier than using regex.
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.
https://i.stack.imgur.com/Y5NCF.png
https://i.stack.imgur.com/k1q9e.png
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
https://i.stack.imgur.com/6QEiA.png
https://i.stack.imgur.com/W0Mmu.png
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
https://i.stack.imgur.com/AYusB.png
https://i.stack.imgur.com/YaW9N.png
For all Notepadd++ Tutorials: VISIT:)
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):
https://i.stack.imgur.com/ao9ru.jpg
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.
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.
https://i.stack.imgur.com/7LKUC.png
Open Notepad++, then click Ctrl+ F.
Choose Regular Expression
*Find What: "^" (which represents index of the each line - "PREFIX").
Replace with : "anyText"*
https://i.stack.imgur.com/Q6Lc8.png
For Suffix on each line: Follow the same steps as above "Replace ^ with $" . That's it.
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.
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.
use the command line cc.gl a to get lines and store in an array named a. use the command line cc.aal //$a to append after each line, using the contents of array a.
https://i.stack.imgur.com/reXoT.gif
In order to do it in one go:
Copy and paste the following example text in your notepad++ window:
http:\blahblah.com http:\blahnotblah.com http:\blahandgainblah.com
Press Ctrl+H on the notepad++ window In the Find what box type: ^(.+)$. 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. In the Replace with box type: WhateverFrontText(\1)WhatEverEndText. Here (\1) means whatever text in a line. Check the check box Wrap around Search mode: Regular expression Result:
WhateverFrontTexthttp:\blahblah.comWhatEverEndText WhateverFrontTexthttp:\blahnotblah.comWhatEverEndText WhateverFrontTexthttp:\blahandgainblah.comWhatEverEndText
Screenshot of the notepad++ options and result:
\1
inside parenthesis in "replace with"? Also it's better to use $1
, \1
is a very old practice.
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!:
Please find the Screenshot below which Add a new word at the start and end of the line at a single shot
https://i.stack.imgur.com/NCNg0.png
Success story sharing
'\);