Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#4445 Toggle Block Comment also truncates a leading 'rem' from the first word of the line in batch files

All
open
nobody
None
5
2013-08-26
2013-08-16
JanisS
No

Steps to reproduce:

  1. Put the following lines in a Windows batch file:
  2. echo.Removing duplicate lines...
    remove-duplicates.pl my_file.txt

  3. Select the two lines above and press Ctrl+Q (or use the menu command Toggle Block Comment).
  4. You would expect:
  5. REM echo.Removing duplicate lines...
    REM remove-duplicates.pl my_file.txt

    However, you get:

    REM echo.Removing duplicate lines...
    ove-duplicates.pl my_file.txt

Discussion

  • FLS
    FLS
    2013-08-26

    Unlike other comment symbols, for example ‘//’ in C++, the ‘REM’ keyword in batch files needs to be followed by a blank.
    Unfortunately, NP++ has defined the batch files comment keyword without a trailing blank. Inserting the trailing blank in the langs.xml file of NP++ will fix the bug. See attached patch for the langs.model.xml file.

       old: <Language name="batch" ext="bat cmd nt" commentLine="REM">
       new: <Language name="batch" ext="bat cmd nt" commentLine="REM ">
    

    However, when putting a comment symbol into a line, NP++ always adds a blank by itself, so this patch will result in two blanks after the ‘REM’, but I think that is tolerable. In any case, NP++ removes all blanks after the comment keyword when the comment symbol is removed.

    FLS

     
  • JanisS
    JanisS
    2013-08-27

    <html><head></head><body>

    Hi,

     
    It does not work, unfortunately. I guess the XML is parsed by trimming the leading/trailing spaces from values and the result is still the same.
    Just a comparison: SciTE uses 'REM ~' for comments in batch files instead of a simple 'REM'. Maybe adding an additional (non-typical) character after the space would resolve this issue.
     
    JS
     
    Gesendet: Montag, 26. August 2013 um 23:04 Uhr
    Von: FLS <f_ls@users.sf.net>
    An: "[notepad-plus:bugs] " <4445@bugs.notepad-plus.p.re.sf.net>
    Betreff: [notepad-plus:bugs] #4445 Toggle Block Comment also truncates a leading 'rem' from the first word of the line in batch files

    Unlike other comment symbols, for example ‘//’ in C++, the ‘REM’ keyword in batch files needs to be followed by a blank.
    Unfortunately, NP++ has defined the batch files comment keyword without a trailing blank. Inserting the trailing blank in the langs.xml file of NP++ will fix the bug. See attached patch for the langs.model.xml file.

       old: <Language name="batch" ext="bat cmd nt" commentLine="REM">
       new: <Language name="batch" ext="bat cmd nt" commentLine="REM ">
    

    However, when putting a comment symbol into a line, NP++ always adds a blank by itself, so this patch will result in two blanks after the ‘REM’, but I think that is tolerable. In any case, NP++ removes all blanks after the comment keyword when the comment symbol is removed.

    FLS

    Attachment: NppPatch_6.4.5_REM_langs.model.xml.patch (3.4 kB; application/octet-stream)


    [bugs:#4445] Toggle Block Comment also truncates a leading 'rem' from the first word of the line in batch files

    Status: open
    Created: Fri Aug 16, 2013 09:30 AM UTC by JanisS
    Last Updated: Fri Aug 16, 2013 09:30 AM UTC
    Owner: nobody

    Steps to reproduce:

     

    echo.Removing duplicate lines...
    remove-duplicates.pl my_file.txt

     

     

    REM echo.Removing duplicate lines...
    REM remove-duplicates.pl my_file.txt

     

    1. Put the following lines in a Windows batch file:
    2. Select the two lines above and press Ctrl+Q (or use the menu command Toggle Block Comment).
    3. You would expect:
    4. However, you get:

       

      REM echo.Removing duplicate lines...
      ove-duplicates.pl my_file.txt

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/notepad-plus/bugs/4445/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/




    </body></html>

     
    • FLS
      FLS
      2013-09-01

      Hi JanisS

      I have tested my workaround (defining "REM " with a blank instead the "REM") and it works for me.

      Did you edit the right langs.xml file? You can test it, when you comment a line and the inserted comment-symbol has an additonal blank - or just use for testing another string, which you have to see when inserting a comment.

      Be aware, that Notepad++ reads the langs.xml file only at startup. So you have to exit Notepad++ after you have changed the langs.xml file and start it again before you can test the changes.

      In my patch, the langs.model.xml file was patched, which is not the correct file. It is the template for the langs.xml file. Please edit the langs.xml file instead manually. Sorry, if it was misleading.

      Regards
      FLS

       
  • JanisS
    JanisS
    2013-09-02

    <html><head></head><body>

    Hi FLS

     
    Strange.
     
    I modified line 36 in langs.xml as well as line 36 in langs.model.xml (in the folder %ProgramFiles%\Notepad++) to:
       <Language name="batch" ext="bat cmd nt" commentLine="REM ">
     
    and restarted Notepad++ but still have the same behavior (I tested on both Windows 7 (32-bit) and Windows 8 (64-bit)).
     
    My current workaround is to put filenames between quotes.
    For calling Perl scripts, one could also use 'perl <filename> etc.' but using 'perl' before the filename is not necessary if a path to the perl executable is specified in %PATH%.
     
    Anyway, I think that adding a trailing space is not a good idea because there may be outer processes/modules etc. which trim leading and trailing whitspaces as unnecessary. The most reliable approach would be to take into account whole words only if possible. The same may also apply to VB code.
     
    Janis
    --
    janissl@web.de
    mob. +371 29243841
     
     
    Gesendet: Sonntag, 01. September 2013 um 21:17 Uhr
    Von: FLS <f_ls@users.sf.net>
    An: "[notepad-plus:bugs] " <4445@bugs.notepad-plus.p.re.sf.net>
    Betreff: [notepad-plus:bugs] Re: #4445 Toggle Block Comment also truncates a leading 'rem' from the first word of the line in batch files

    Hi JanisS

    I have tested my workaround (defining "REM " with a blank instead the "REM") and it works for me.

    Did you edit the right langs.xml file? You can test it, when you comment a line and the inserted comment-symbol has an additonal blank - or just use for testing another string, which you have to see when inserting a comment.

    Be aware, that Notepad++ reads the langs.xml file only at startup. So you have to exit Notepad++ after you have changed the langs.xml file and start it again before you can test the changes.

    In my patch, the langs.model.xml file was patched, which is not the correct file. It is the template for the langs.xml file. Please edit the langs.xml file instead manually. Sorry, if it was misleading.

    Regards
    FLS


    [bugs:#4445] Toggle Block Comment also truncates a leading 'rem' from the first word of the line in batch files

    Status: open
    Created: Fri Aug 16, 2013 09:30 AM UTC by JanisS
    Last Updated: Mon Aug 26, 2013 09:04 PM UTC
    Owner: nobody

    Steps to reproduce:

     

    echo.Removing duplicate lines...
    remove-duplicates.pl my_file.txt

     

     

    REM echo.Removing duplicate lines...
    REM remove-duplicates.pl my_file.txt

     

    1. Put the following lines in a Windows batch file:
    2. Select the two lines above and press Ctrl+Q (or use the menu command Toggle Block Comment).
    3. You would expect:
    4. However, you get:

       

      REM echo.Removing duplicate lines...
      ove-duplicates.pl my_file.txt

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/notepad-plus/bugs/4445/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/




    </body></html>