Notepad++ add to every line

后端 未结 13 1835
无人共我
无人共我 2020-11-29 14:18

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.

相关标签:
13条回答
  • 2020-11-29 14:37

    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.

    0 讨论(0)
  • 2020-11-29 14:44

    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!:

    See the image here

    0 讨论(0)
  • 2020-11-29 14:45

    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.

    0 讨论(0)
  • 2020-11-29 14:48

    Follow these steps:

    1. Press Ctrl+H to bring up the Find/Replace Dialog.
    2. Choose the Regular expression option near the bottom of the dialog.

    To add a word, such as test, at the beginning of each line:

    1. Type ^ in the Find what textbox
    2. Type test in the Replace with textbox
    3. Place cursor in the first line of the file to ensure all lines are affected
    4. Click Replace All button

    To add a word, such as test, at the end of each line:

    1. Type $ in the Find what textbox
    2. Type test in the Replace with textbox
    3. Place cursor in the first line of the file to ensure all lines are affected
    4. Click Replace All button
    0 讨论(0)
  • 2020-11-29 14:50

    Open Notepad++, then click Ctrl+ F.

    Choose Regular Expression

    *Find What: "^" (which represents index of the each line - "PREFIX").

    Replace with : "anyText"*

    For Suffix on each line: Follow the same steps as above "Replace ^ with $" . That's it.

    0 讨论(0)
  • 2020-11-29 14:51

    In order to do it in one go:

    1. Copy and paste the following example text in your notepad++ window:

    http:\blahblah.com

    http:\blahnotblah.com

    http:\blahandgainblah.com

    1. Press Ctrl+H on the notepad++ window
    2. 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.
    3. In the Replace with box type: WhateverFrontText(\1)WhatEverEndText. Here (\1) means whatever text in a line.
    4. Check the check box Wrap around
    5. Search mode: Regular expression
    6. Result:

    WhateverFrontTexthttp:\blahblah.comWhatEverEndText

    WhateverFrontTexthttp:\blahnotblah.comWhatEverEndText

    WhateverFrontTexthttp:\blahandgainblah.comWhatEverEndText

    1. Screenshot of the notepad++ options and result:
    0 讨论(0)
提交回复
热议问题