How to remove the space when commenting lines?
-
Every time I press Ctrl+Q the text is commented in this way:
; instructionsBut I want it to be that way:
;intructionsHow can I do that? It is not useful to replace the text "; " by “;” as this way it is not portable to other languages.
-
@Willy said in How to remove the space when commenting lines?:
the text is commented in this way:
If you were to read the Notepad++ documentation, specifically the config files it may help. See:
https://npp-user-manual.org/docs/config-files/Look for the langs.xml file detail. I presume you have a specific language you are using, perhaps ASM files. It would appear that you can define the comment start characters by editing this file.
I haven’t tried this.Good luck
Terry -
@Terry-R Hi, that’s what you’re saying is to change the character for another one, that’s not my problem, my problem is that notepad++ always adds a space when I comment and that’s what I want to avoid, I read the langs.xml file and look at this line for the Ruby language:
<Language name="ruby" ext="rb rbw" commentLine="#">
As you see there are no spaces in the “#” character so it’s not like I can do anything to take the space away, it’s something from Notepad++
-
@Willy said in How to remove the space when commenting lines?:
As you see there are no spaces in the “#” character
Actually from my limited knowledge of this setting I’d say NPP isn’t interpreting your code as Ruby, otherwise it would have used the
#
as you show from the langs.xml file, not the;
. I also note that#
is the comment line for Ruby in the real world. What file extensions are you using? That may be how NPP is acknowledging the code, so look in the langs.xml file again for the extensions you are using and check the relevant comment info.Terry
-
@Willy said in How to remove the space when commenting lines?:
not like I can do anything to take the space away, it’s something from Notepad++
You may be right here. I’ve completed some testing selecting various languages and each time I press the Ctrl-Q shortcut it inserts the comment character(s) for the selected language, and then appends a
space
. It does prove you aren’t selecting Ruby as the language or using the ruby file extensions though as you get the;
, not the#
character.So regardless of which language is selected it would appear the default setting is to
append
a space behind thecommentLine
character specified (in langs.xml file) according to language/file extensions. This would need to be raised as a bug (? not surebug
is the right word, the developer has probably just decided that’s the correct approach) on GitHub I think. I believe that’s where all these things are worked on, not on this forum.Terry
-
@Terry-R “my problem is that notepad++ always adds a space when I comment”
So no matter what language I’m working on, I’ll use Ruby, C, C++, Assembler whatever and I don’t want the space when commenting, that’s it.
I didn’t say Notepad++ was changing the “#” to “;” or anything like that, I just picked a language at random and it was Ruby, all languages have the comment character without the space in langs.xml so where should I go? Github?
If I go to Github what I’d be asking is that they implement the function and obviously that takes time, I wanted something fast, maybe something I was ignoring.
You insist that Github is my only option? If so, I’ll go to Github.
-
@Willy said in How to remove the space when commenting lines?:
my problem is that notepad++ always adds a space when I comment
And I agreed (after testing) with that statement. I’m also saying I don’t think it’s a bug. Consider what you are doing. You are entering a comment. Regardless of which language you code in comments are ALWAYS regarded as “free speech” (to my knowledge). I don’t see the issue with having a space before your “comments”. If indeed there is an issue then it can’t be a
real
comment, it would seem you are using this “code type” for other purposes, thus needing an exact format.You can look through various posts here (use search) for github to find the links, however as I say, consider what you are asking for. I doubt VERY much it would be considered a bug at all. I don’t see it anywhere in settings/preferences so it’s not overridable (to my knowledge).
Terry
-
Actually, why not consider it a “feature request”.
See:
https://community.notepad-plus-plus.org/topic/15741/faq-desk-feature-request-or-bug-reportTerry
-
@Terry-R No, I don’t consider it a error/bug, I just need that functionality, and yes, you are right that a comment is a comment and that space shouldn’t matter, it even seems a bit immature the request but the code already has that style in several lines and I can’t ruin the code with a different style, it wouldn’t be constant.
Use whatever style you want but be constant and don’t mix styles, I was taught that way.
-
@Willy said in How to remove the space when commenting lines?:
don’t mix styles
That’s a fair comment. Why not use a regex (regular expression) that you run as you do the final save of the file. It can remove that space at the start of the comment lines fairly easily. Otherwise go through ALL the old code and change them to suit the current format. That’s probably going to be the quickeest way to sort it out (short to medium term). Then ask for a feature request. It’s a valid request, but I don’t think it’s a valid bug.
Terry
-
@Terry-R These are valid options and I did think of them, but I was hoping there was a way to configure notepad++ without doing anything, I’ll try my luck on Github and thanks for everything.