Notepad++ is one of my favorite applications on Windows because of all of the functionality it provides. One thing I needed to do recently was to add text to the end of each line in a text file but I wasn’t sure exactly how to do it without a little research. Below is information on how to both append data to every line in a text file and how to prefix data to every line in a text file.

Append Data To Every Line In A Text File With Notepad++:

  1. Open Text File: First open the text file you want to append data to every line in Notepad++. In this example I have a list of 19 password hashes and passwords as shown in the below image that I want to append the hash type to the end of the file.

    Notepad++ Text File With List Of Hashes

  2. Notepad++ Search & Replace: Click Search in the top navigation bar and then scroll down to click Replace as shown in the below example image.

    Notepad++ Menu: Search & Replace

    Once you click Replace it will open the Replace tab in the Notepad++ Find window as shown below.

    Notepad++ Replace Tab In Find Window

  3. Modify Search Mode: Now you need to make sure and change the Search Mode to Regular Expression by clicking the radio button next to “Regular Expression” as shown in the below image. The Search Mode is configured in the bottom left of the Search window.

    Notepad++ Search Mode: Regular Expression

  4. Append Text: In the “Find What” field you should enter “^(.+)$” without he quotes which will find every line of text and in the “Replace With” field you will enter “\1<text to append”. The \1 is text located from the Find What field which will be followed by whatever you want to append to each line. In the example below we will be appending :SHA.

    Notepad++ Append Data To Every Line

    Once you have filled in Find What and Replace With click the Replace All button which will add the text after the 1 to every line and display a popup confirmation displaying how many lines were modified.

    Notepad++: Replace All Confirmation Popup

    The initial list of hashes will now all have :SHA at the end of each line as shown in the below example image.

    Notepad++: Data Appended To Every Line

Now save the file and data is appended to every line. If you want to prefix each line with data in Notepad++ simply add the data you want to prefix before the “\1″ in the Replace With box and then click the Replace All button to make the modification to the text file.

Mastering Regular Expressions (Paperback)

By (author): Jeffrey E. F. Friedl


List Price: $44.99 USD
New From: $25.00 USD In Stock
Used from: $14.29 USD In Stock

Regular Expressions Cookbook (Paperback)

By (author): Jan Goyvaerts, Steven Levithan


List Price: $44.99 USD
New From: $39.01 USD In Stock
Used from: $11.50 USD In Stock

DeliciousStumbleUponDiggTwitterFacebookRedditLinkedInEmail
Tags: , , , , , , ,
36 Responses to “Append Text To Each Line In Notepad++, Prefix Text To Every Line In Notepad++”
  1. dd says:

    omg you have no idea how much time this is going to save me now.. I really appreciate this guide you made with screenshots on how to append text in notepad++

    NPAD++ is free and it’s the best!

    [Reply]

    alex Reply:

    Hello dd,

    No problem at all. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  2. john tossot says:

    Hello alex, Thank you for this useful tutarial. I have a question that how to add tag at the start of each line? Please answer me.

    [Reply]

    alex Reply:

    Hello john,

    No problem. I am not sure what you mean by “tag” to the beginning of each line. We answer all comments on our site so no need to request for an answer.

    Thanks.
    alex

    [Reply]

    john tossot Reply:

    alex i mean that how to add any text in thes start of every line of text file. For example a file.txt which contin three lines as following:
    line 1
    line 2
    line 3
    My question is that how to add tag at the start of every line so it’s result will as below:
    line1
    line2
    line3
    I hope you understand and can solve my problem. And agin thanks for useful articles on this site.

    [Reply]

    alex Reply:

    Hello john,

    Sorry I am still not 100% sure…

    If you have the below example….

    #######################
    Hello how are you.
    Good I am fine.
    #######################

    you want it to be….

    #######################
    1234 Hello how are you.
    1234 Good I am fine.
    #######################
    ?

    If you can write out more of example instead of using line1, line2, etc. it may click for me. :)

    The good news is that you can likely do what you want with Notepad++ because it is awesome software. :)

    Thanks.
    alex

    [Reply]

    Nico Reply:

    Hello

    This guy did not reply. ANyway, I am interested in the answer. How to add text at the begining of each line. I have a list of sites (one on a raw) and i want to add http:// at the beginning of each site because they do not have. How can I do this?

    [Reply]

    alex Reply:

    Hello Nico,

    Again I would need a specific example of say two lines that you want to modify and I can provide a solution specific for your issue. There are likely more ways to accomplish the goal. I would personally use find/replace for the adding http://. You could find www. and replace it with http://www. As for the other you can again use the find/replace window and switch the search mode to Regular Expression. Next click on the replace tab and search for “^(.*)$” without the quotes and put “WHATEVER YOU WANT TO ADD TO THE BEGINNING HERE\1″ in the replace field and again without the quotes. Click the replace all button and you will add text to the beginning of each line. Hope that helps.

    Thanks.
    alex

  3. dewey says:

    omg thank you so much! the ^(.+)$ was exactly what I was looking for. I knew there had to be a way to do it in N++ but I couldn’t find it anywhere else on the web. it’s going to make life SO much easier! really appreciate you putting this info up. thanks!

    [Reply]

    alex Reply:

    Hello dewey,

    No problem at all. Thanks for taking the time to leave feedback. It is always nice to get positive feedback on the articles we post!

    Thanks.
    alex

    [Reply]

  4. Eduardo says:

    very good tutorial but you have a advanced notepad? because the mine is very poor.

    [Reply]

    alex Reply:

    Hello Eduardo,

    Yes… this is not done with the typical Notepad but instead using Notepad++ which is referenced in the article. A quick Google search will lead you to Notepad++ and greener pastures.

    Thanks.
    alex

    [Reply]

  5. th says:

    THX YOU … YOU SAVE MY MANY TIME … YOU ARE AMAZING.. THX AGAIN!!!

    [Reply]

    alex Reply:

    Hello th,

    No problem. Thanks for taking the time to leve feedback.

    Thanks.
    alex

    [Reply]

  6. rajczar says:

    thanks for this amazing tutorial…saved me lots of time and effort

    did a little search for regular expressions n found this thru experimenting
    1. to ONLY append to each line we can just use “$” in ‘find what’
    2. to ONLY prefix to each line we can just use “^” in ‘find what’

    but to use both at the same time we need to use “^(.+)$” in ‘find what’ and ” \1″ in the
    ‘replace with’ and use the format PREFIX\1APPEND

    [Reply]

    alex Reply:

    Hello rajczar,

    No problem. Thanks for adding the above information and for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  7. GD says:

    Thanks for the fantastic tips.
    Wondering if the following is possible.
    Want to take text from a line and insert or append to the end of the line.
    Example
    get workgroup “test1″ > “.xml”

    So I am trying to take the data between the “quotes” and copy/insert in front of the .xml

    Result should look like this
    get workgroup “test’” > “test1.xml”

    [Reply]

    alex Reply:

    Hello GD,

    Pretty much anything is possible so after briefly looking at the above I would say that yes it is possible. If you look up regular expression and what you are trying to do above on Google you will likely come up with the answer.

    Thanks.
    alex

    [Reply]

  8. Stefan says:

    Great post…it really helps solving the problem

    Best Regards

    [Reply]

    alex Reply:

    Hello Stefan,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  9. Peter says:

    it is very surprising that a very common task like this is not implemented in notepad++ in a more human readable manner

    [Reply]

    alex Reply:

    Hello Peter,

    Yeah that would definitely make things easier. :) Thanks for posting feedback.

    Thanks.
    alex

    [Reply]

  10. Redox says:

    I have been trying to do it for more than 3hrs now… :) and it is THAT simple :) HUDGE thanks whoever U are :)

    [Reply]

    alex Reply:

    Hello Redox,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  11. Iftikhar says:

    thanks alotttttttttttt Alexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx , Love you Alllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll, God Bless you

    [Reply]

    alex Reply:

    Hello Iftikhar,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  12. Sulfikkar BS says:

    I have the below list of tables

    vw_FTP_Cross_Ref_Report_LastD_IM0409426
    KRM_Reprice_Gap_Results_IM0370135
    KRM_FTP_1DD_Results_MTD_SD1546057
    KRM_FTP_1dd_results_MTD_IM0415176
    ftp_prem_2dd_mtd_SD1434664
    FAD_FTP_1DD_Results_IM0409426
    TRDEAL_Dates_IMO
    TRDEAL_PRICES_IM0400882
    vw_REPLIC_PORTFL_CASH_IM0406910
    TRDEAL_MUREX_Live_Deals_IM0402496_2
    TRDEAL_PRICES_IM0430206
    TRDEAL_Keys_IM0430206
    TRDEAL_BALANCES_IM0433963
    TRDEAL_COUPONS_NEW_IM0433963
    TRDEAL_COUPONS_NEW_SD1575002
    TRDEAL_BALANCES_SD1480835
    TRDEAL_PRICES_SD1406510
    QUADRUS_Coupon_EquityBasketStrike_SD1403399
    QUADRUS_List_Curve_SD1399424
    TRDEAL_BALANCES_SD1612593
    quadrus_trades_generic_SD1421369
    quadrus_trades_current_SD1421369
    quadrus_trades_previous_SD1421369
    TRDEAL_COUPONS_NEW_SD1472684
    QUADRUS_Coupon_ReverseDualCCY_SD1478161
    TRDEAL_BALANCES_SD1519880
    TRDEAL_MKTVALUE_DIRTY_SD1424623
    TRDEAL_BALANCES_SD1508241
    trdeal_coupons_new_SD1458081
    TRDEAL_BALANCES_SD1528495
    TRDEAL_COUPONS_NEW_SD1494237
    Quadrus_List_Curve_SD1536748
    quadrus_trades_previous_SD1615675
    TRDEAL_BALANCES_SD1515787
    TRDEAL_MKTVALUE_DIRTY_SD1458081
    TRDEAL_COUPONS_NEW_SD1579949
    TRDEAL_BALANCES_SD1487721
    TRDEAL_BALANCES_SD1467864
    QUADRUS_Coupon_CfDualCCYTargetRedemption_SD1625852
    Quadrus_Coupon_EquityBasketPerformance_SD1626223
    TRDEAL_SOURCES_SD1581465
    TRDEAL_COUPONS_NEW_SD1593369
    QUADRUS_List_Curve_SD1401267
    BasisRiskPremium_Rates_SD1542204
    BasisRiskPremium_Rates_SD1576082
    MRU_equities_SD1643170
    MRU_FXSpot_SD1547746
    MRU_FXSpot_SD1568712
    MRU_Indexes_SD1592810
    MRU_Indexes_SD1634031
    MRU_MUREX_index_mapping_risk_SD1597634
    MRU_Rates_SD1502494
    MRU_Rates_SD1543671
    MRU_RATES_SD1547746
    MRU_Rates_SD1568712
    MRU_rates_SD1578182
    MRU_Rates_SD1578198
    MRU_Rates_SD1603549
    MRU_Rates_SD1622663
    MRU_Rates_SD1622677
    PREM_Rates_SD1421369
    prem_rates_SD1423944
    PREM_rates_SD1441165
    prem_rates_SD1461680
    prem_rates_SD1466032
    PREM_Rates_SD1503039
    PREM_Rates_SD1510948
    PREM_Rates_SD1513603
    PREM_Rates_SD1541404
    PREM_rates_SD1561121
    PREM_RATES_SD1578182
    KRM_PLUG_2DD_CURRENT_IM0413056_3
    temp_map_dept_IM0406910
    MUREX_Coupon_2nd_Leg_IM0432134
    PREM_Mapped_EOD_Current_IM0441096
    PREM_Mapped_EOD_Current_IM0434516
    MUREX_RateSets_IM0432134
    PREM_Mapped_EOD_Current_IM0434516_1
    Murex_Extract_IM0432134
    PREM_Mapped_EOD_Current_IM0441096_1
    PREM_Mapped_EOD_Current_IM0441096_2
    KRM_PORT_1DD_Previous_IM0406910
    KRM_PORT_1DD_CURRENT_IM0406910_1
    KRM_PORT_1DD_CURRENT_BackUp_IM0406910
    KRM_PLUG_2DD_CURRENT_IM0417048_1
    TRDEAL_COUPONS_NEW_IM0433963
    TRDEAL_BALANCES_IM0433963
    KRM_PORT_1DD_CURRENT_IM0406910
    krm_plug_2dd_current_IM0435114
    TRDEAL_COUPONS_NEW_IM0433963_1
    TRDEAL_COUPONS_NEW_IM0402496_2
    TRDEAL_BALANCES_IM0402496_2
    TRiuMPHDeal_Extract_IM0413056
    TRDEAL_COUPONS_NEW_IM0402496
    TRDEAL_BALANCES_IM0402496
    KRM_PLUG_2DD_CURRENT_IM0413056
    KRM_PLUG_2DD_CURRENT_IM0413056_2
    KRM_PLUG_2DD_CURRENT_IM0413056_1
    MUREX_RateSets_IM0423917
    MUREX_RateSets_IM0401495
    Murex_Coupon_2nd_Leg_IM0423917
    MUREX_Coupon_2nd_Leg_IM0401495
    Murex_ratesets_IM0433450
    MUREX_Extract_IM0401495
    Murex_Coupon_2nd_Leg_IM0433450
    KRM_PLUG_2DD_CURRENT_IM0417048_2
    KRM_PLUG_2DD_CURRENT_IM0417048_3
    KRM_PLUG_2DD_CURRENT_IM0417048
    MUREX_Cashflows_IM0439193
    LIS_Option_Transactions_IM0415969
    MUREX_Coupon_2nd_Leg_IM0431217
    MUREX_RateSets_IM0431217
    Murex_Extract_IM0431217
    FacitAmort_Extract_SD1418108
    FacitFacilities_Extract_SD1632237
    Map_Source_GLPdct_I_SD1459583
    Map_Source_GLPdct_I_SD1483564
    Map_Source_System_SD1494237
    Map_Source_System_SD1502494
    map_source_system_SD1536036
    map_source_system_SD1597864
    Map_Source_System_SD1605921
    Map_Source_System_SD1651348
    matrixsecurities_extract_15May2012_SD1597425
    matrixsecurities_extract_16May2012_SD1597425
    Prem_Mapped_1DD_Current_SD1562242
    PREM_Mapped_2DD_Current_SD1423571
    Prem_Mapped_2DD_Current_SD1620165
    trmp_deal_rec_SD1575527
    PRem_rates_SD1583821
    prem_rates_SD1614028
    QUADRUS_Correlations_SD1590617
    QUADRUS_Esv_Requests_SD1401267
    QUADRUS_Esv_Requests_SD1615675
    QUADRUS_Esv_Results_SD1399424
    QUADRUS_Esv_Results_SD1643170
    QUADRUS_Esv_VolManData_SD1471815
    Quadrus_ESv_VolManData_SD1541875
    Quadrus_ESv_VolManData_SD1622699
    swaps_PL_IM0413479
    SWAPS_PL_IM0413479_1
    SWAPS_PL_IM0430206
    tbl_GapPVBPData_IM0418049
    tbl_GapPVBPData_IM0418049_1

    I want add two words namely drop table infornt of each line.
    for eg first line would be as below
    drop table vw_FTP_Cross_Ref_Report_LastD_IM0409426
    Can you please reply asap

    [Reply]

    alex Reply:

    Hello Sulfikkar BS,

    The article describes exactly what you are trying to do.

    Thanks.
    alex

    [Reply]

  13. Mezo says:

    Hello Alex ,
    Any way to add a specific word at the start of every line in the Notepad ?!!
    What’s the code that I should insert instead of โ€œ^(.+)$โ€ ?!!
    Thanks in advanced ,
    Mezo

    [Reply]

    alex Reply:

    Hello Mezo,

    Say you wanted to add “test ” to the beginning of each line you would first make sure Regular Expression is selected in the Find and Replace pop up window. Then you would populate the following two fields with the data below…

    Find What: ^(.+)$
    Replace With: test \1

    Click the Replace All button and you should now have “test ” before each line.

    Hope that helps.

    Thanks.
    alex

    [Reply]

  14. Mike says:

    Only problem I see with this so far is that if the text you are inserting is something with brackets ( and ) it will remove them. There are likely other characters as well. I got around this by changing them to { and } then doing a replace all on them.

    [Reply]

  15. Shane Ponting says:

    Searched for how to prefix each line in a text file and found this. Nice! Works a charm, solution to my problem!

    [Reply]

    alex Reply:

    Hello Shane,

    Glad to hear it helped you out. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  16. Julie says:

    You just saved me an enormous amount of work. Thank you!

    [Reply]

    alex Reply:

    Hello Julie,

    No problem. Thanks for posting feedback.

    Thanks.
    alex

    [Reply]

  17. Patrick says:

    There is a typo on step 4. You say “โ€œ\1″ to the end so it says: “\1″

    Just thought I’d throw that out there

    [Reply]

  18.  
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*