Menu

replace with delete to end of line

census1940
2008-10-05
2012-11-13
  • census1940

    census1940 - 2008-10-05

    Group,

    I have a situation I can't resolve.  I have a text file involving definitions of census enumeration districts with many lines that is used for a database on a website.  Let's say the line looks like:
    code^San Francisco  (n) xyz; (e) abc; (s) def; (w) ghi.

    let's assume that I want to redo this line (and 1200 or so other lines of San Francisco) to look like:
    code^San Francisco Use The MNO Utility

    I can do a global replace of San Francisco with the city and new phrase, but I can't figure how to delete after that to the end of the line.  Since each line has different entries in the (n), (e), ...etc. spots, I can't specify a single search for the entire line.

    Right now I'm using autohotkey and placing the mouse after San Francisco on each line, pressing a rekeyed F12, and the short autohotkey program is deleting to the end of the line, and adding the additional phrase, but I have to move the mouse to every line.

    It would be nice if I could do a global replace on notepad++ to both replace the city to a city/phrase and at the same time delete to the end of the line.  If I try to "replace" with " San Francisco Use The MNO Utility Shift Alt Delete"  I'm not allowed to  do that.  I've tried different tricks without success.  Any ideas?  Is this possible to do within notepad++?

    Thanks

    census1940

     
    • census1940

      census1940 - 2008-10-06

      thanks pshute... this area of notepad++ looks promising for what I need.  I'll digest the info.

       
    • Fool4UAnyway

      Fool4UAnyway - 2008-10-05

      Did you scan the headlines on this forum's opening page for similar problems?

      Which search terms did you use to find any other messages about this problem?

      SourceForge is only making things worse, currently, because the page load times are only still increasing. If you want to get quicker results, please go to the SourceForge Community forum by clicking on the Feedback link in the lower right corner of this page. Ask to "give us the old SourceForge back".

       
    • pshute

      pshute - 2008-10-06

      I think you need to investigate regular expressions.  See http://notepad-plus.sourceforge.net/uk/regExpList.php for more details.  I think you'd replace:
      code^San Francisco .*
      with:
      code^San Francisco Use The MNO Utility
      but test it before you try it on the real thing.

      If the file is sorted so that all of the San Francisco lines appear together, then you could also do a block delete.  See the column mode election section in http://notepad-plus.wiki.sourceforge.net/FAQ for details.