Menu

Editing multiple lines at same time

2008-01-03
2012-11-13
  • Nobody/Anonymous

    Can I edit multiple lines in a single document at the same time, without going through the whole document line-by-line? Like this:

    Before editing:
    test 1
    test 2
    test 3

    After editing:
    test A
    test A
    test A

     
    • Nobody/Anonymous

      Just to clarify, I would like to make an "extended cursor" at the end of all the similar lines and write/use backspace/etc so that it affects all the selected lines at the same time.

      The sample case I gave would be possible just by using Shift-key when selecting text.

       
      • Nobody/Anonymous

        Could the originator of this post rewrite and perhaps rethink the question - please

         
        • Nobody/Anonymous

          Or perhaps search for existing messages about column mode if that's what he is looking for.

           
          • pshute

            pshute - 2008-01-03

            Yes, the Column Editor may be what you want.  http://notepad-plus.wiki.sourceforge.net/FAQ includes a small discussion about selecting column blocks.  Then use Edit/Column Editor or alt+c to activate the column editor.  You can use it to insert or overwrite columns of text.

             
            • Nobody/Anonymous

              Sorry, my description was poor. English is not my native language. :-)

              I meant a feature where I can edit multiple lines simultaneously, like with Ultraedit, where I can grab the lower or upper end of the cursor and extend it so that it affects multiple lines. Therefore it is not the replace function. I can try to illustrate the effective need of the feature like this:

              Imagine having e.g. extremely many Windows service user folders and you want to delete them with a commandfile with command rmdir. The users (profile foldernames) could be something like:

              sJfHAOlzLO2YsAqnOhvJ
              w4MCCCQAdv89Ju1FBK1L

              If I would like to delete the folders like this:

              rmdir /s /q sJfHAOlzLO2YsAqnOhvJ
              rmdir /s /q w4MCCCQAdv89Ju1FBK1L

              It would be useful to extend the one and only cursor at the beginning of the foldernames so that when I type "rmdir /s /q", the text appears at the beginning of each folder. This is not a perfect example, since it could be done with Column Editor also.

               
              • Nobody/Anonymous

                This is something I would typically use the Find/Replace function for.

                Select the lines you want to prefix.
                Check regular expressions.
                Enter in the Find Field:
                ^(.+)
                Enter in the Replace Field:
                rmdir /s /q \1

                Replace all.

                Or do not use regular expressions, but simply replace each End-Of-Line character _of the previous line_ by and EOL + rmdir /s /q. Notice that you should select the line before the first and exclude the last EOL from you selection when doing this.

                Use the CTRL+R Find/Replace Dialog for this and the CTRL+M or CTRL+Enter key to enter the EOL in the find and replace fields.

                 
              • fidvo

                fidvo - 2008-01-04

                Or you could use the Simple Script plugin.

                (Disclaimer: I'm the developer of Simple Script)

                I added the beginline and endline functions specifically for tasks like this, because I find it easier to remember a single function name than the syntax for the regular expression.  In this case, the script would be:

                beginline("rmdir /s /q ")

                 
    • Nobody/Anonymous

      I meant Alt-key, not Shift...

       
    • Nobody/Anonymous

      The search box has a replace all button.

      search for   test \d
      replace      test A

      hit "Replace all" button