Menu

How do I do this?

abc1232
2009-09-04
2012-11-14
  • abc1232

    abc1232 - 2009-09-04

    Suppose and have a block of line in the np++ editor and want to delete everything start from certain column, how do I do that?  Thanks ahead...

    e.g. I want to delete everything left of E for every line.

    ABCDEFGHIJKLMNOP
    ABCDEFGHIJKLMNOP
    ABCDEFGHIJKLMNOP
    ABCDEFGHIJKLMNOP

     
    • abc1232

      abc1232 - 2009-09-09

      Thanks for the tips everyone.  Those were very helpful...  :)

       
    • Glenn

      Glenn - 2009-09-04

      Short of replacing 'ABCD' with nothing (I know that is not what you intended), or using the macro functions (not sure that would do it either), I do not think it can be done.  Never seen any editor that could without some kind of macro.

       
    • Fool4UAnyway

      Fool4UAnyway - 2009-09-04

      Perhaps you could be a little more specific, so any answer could be more accurate.

      I suggest you read about (search the forums for) regular expressions, possibly in combination with words like delete and start (of) line.

      In your example case, possible solutions are:

      1. Block selection and deletion.

      Select all lines you want to delete the first four characters of (although your descriptions says  "delete everything start FROM certain column"). Move cursor to the first line, press and hold down Shift, move cursor to the last line, press CursorRight three times, then press and hold down Alt (and still Shift), press CursorRight one more time. Now you have selected the first four columns on all desired lines. Press Delete to delete this columnar selection.

      2. Delete the first four characters on each (selected) line by a "simple" regular expression.

      Select all lines the normal way, no block selection, do not use Shift.
      Press Ctrl+R to open the Text FX Advanced Find/Replace Dialog.

      In the Find Field, enter:
      ^....

      Leave the Replace Field blank.

      Mark the Regular Expr checkbox on the right side.
      Mark the 1 per line  checkbox on the right side.

      Find and Replace (Rest) all occurrences.

      It can't be done this way using the normal Ctrl+H Replace Dialog, because it will recursively remove the first four characters of each processed line. So you will only be left with the last 3, 2 or 1 characters of each line. This is a shortcoming in the regular expression engine. As soon as it did process the ^ start of a line, it should never accept the remainders of it as the "start" again (unless, of course, the Recurse Repl checkbox in the Ctrl+R Dialog is checked).

      3. Delete all non-matching characters from the start of a line

      Using the following regular expression you can delete all characters until the first E on each line.

      Find Field:
      ^[^E]+

      4. You may find more specific examples by searching the forums.

       
    • cchris

      cchris - 2009-09-04

      If your lines are all of the same length, I'd do this:
      move crsor before the 1st character to delete, and alt+click there
      alt+shift+down until the last line to operate on
      alt+shift+end to select the whole block of text
      delete

      If all lines don't have the same length, repeating the procedure may help

      HTH
      CChris

       
MongoDB Logo MongoDB