add block comments in langs.xml?
mathlete2 last edited by
The default NP++ batch script highlighting correctly identifies two types of comments:
::. However, all of NP++'s commenting shortcuts (CTRL+K, CTRL+Q, and CTRL+SHIFT+Q) work with
Based on the content in langs.xml, this makes sense: the section for Batch only has a definition for
commentLine. However, the sections for other languages (like ActionScript) have additional definitions for
commentEnd. Based on simple tests, these seem correspond to the Block Comment shortcut.
Some of the
comment*definitions for other sections are empty (i.e.
commentEnd=""), so I would expect that adding
commentStart="::" commentEnd=""to the Batch section would change its CTRL+SHIFT+Q shortcut to the
::comment style. Unfortunately, this does not seem to work for me when I try it. Is there another step I’m missing, or am I looking in the wrong place altogether?
note: I’m sure I could implement this with a UDL, but that seems like an extreme solution.
PeterJones last edited by
It’s not working because commentEnd must be non-blank if you want commentStart to work. If I set it to
<Language name="batch" ext="bat cmd nt" commentLine="REM" commentStart="::" commentEnd="::REM">, save, exit, reload, then load a file in Batch, the Ctrl+Shift+Q will block-mode, where it puts
::at the beginning of the current selection and
::REMat the end of the current selection; but if I set
commentEnd="", it will instead just use the commentLine for the block-comment commands as well, ignoring both commentStart and commentEnd. I tried some experiments, and even if you did something as simple as
commentEnd=" "(where it uses a single space in the attribute value), it will use
::for the beginning and a space for the end.
But please note, if you do get it working that way: block comments are meant to allow for multi-line, and abusing cmd.exe’s label syntax (which is actually what
::is for) to be a pseudo-comment will not create a multi-line comment in cmd.exe syntax. It would just put
::at the beginning of the selection and whatever non-empty text you chose for the commentEnd at the end. Which means, if you have more than one line selected, only the first line would be commented out.
If you want to use
::as your line comment, then you should just change
commentLine="::", and then line-comment will always use that (and block comments will instead apply the line-comment individually to all selected lines). But you cannot set it up in a way soas to have two different single-line comment syntaxes, as that is not how the comment-feature was designed.
(we literally just added the text
These attributes can only define one type of line and block comments; if your language has multiple types of either, you will have to choose the _one_ type that you'd like Comment/Uncomment to work with.to the user manual: it hasn’t even had time to be released to the website yet. but it will be in the next revision of the website.)