settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?
-
settings–preference–language style setting–bash–instruction word,is the keywords has number or word limit?
when i input api、all or any other words, the bash text not highlight. -
@ljhmily said in settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?:
when i input api、all or any other words, the bash text not highlight
Are you working on a file which has already been saved and has an extension such as listed on the screen you refer to (bash sh bsh csh bash_profile bashrc profile). Otherwise Notepad++ has no idea that’s what your intention is.
The tab header will confirm the file name, or possibly it is just “new 1”, or “new 2” etc.
Terry
-
@Terry-R yeah, my file is xxxx.bash, i added some keywords, like su wget api ssh, but only su wget ssh worked, the api and others not.
-
@ljhmily said in settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?:
like su wget api ssh, but only su wget ssh worked, the api and others not.
I don’t personally use this feature (not a programmer , yet) so I might be on the wrong track, but a quick test showed that the word you add must be of the same case as in the file. So if added “api” then “api” must be in file, not “API”.
I added several dumb words in my test and all highlighted if of same case as added.
Terry
-
@Terry-R said in settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?:
but a quick test showed that the word you add must be of the same case as in the file.
Actually a further test seems to show only the word against the margin will highlight if amongst the user added words. That might be a feature of the “bash” coding that Notepad++ has used as a rule?
Terry
-
@Terry-R yes, my content like “i use ssh tools to debug some api for testing”, “ansible -vv api -m copy”, but it’s not work.
-
@ljhmily said in settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?:
i added some keywords, like su wget api ssh, but only su wget ssh worked, the api and others not.
su
andwget
are already keywords (INSTRUCTION WORD), so you don’t need to add them.And when I add
api ssh
to the list, they immediately start highlighting:But, as @Terry-R said,
further test seems to show only the word against the margin will highlight if amongst the user added words
It’s more nuanced than that, as shown by my screenshot:
cat api
only markscat
as a keyword because in the grammar of bash,cat
is in the location of a command, butapi
is not (it’s the argument, not the instruction). Butapi blah
at the beginning of the line will allowapi
to be recognized as an INSTRUCTION WORD, because it is grammatically where an instruction should be. Further, on my examples with|
pipes and&
or;
separators, the first word after the separator can also be recognized as an INSTRUCTION WORD, too… because they are instructions.You might try to argue that something like
should highlight thels
as well as thessh
, becausels
is also a command… but really, it’s not a command in terms of the bash script running on the local machine – it’s only a command once it’s sent all the way to the remote connection.similarly,
ansible -vv api -m copy
has-vv
,api
,-m
, andcopy
as arguments, not as instructions, so only theansible
is a potential instruction word… and since it’s not a builtin keyword nor in my list of user-defined keywords, it is not highlighted.So, personally, I consider the bash/unix-shell syntax highlighter to be working correctly; according to the grammar that’s built into the lexer, it is highlighting the builtin or user-defined keywords when they are grammatically being used as instruction words, and only then. If you consider that a bug (I do not), this forum is not the right place to report it; in fact, the Notepad++ project is even the wrong place to report it, because the bash lexer is defined/coded in the Scintilla project which Notepad++ uses for that feature. You would have to go report that bug to Scintilla; once/if they fix it, you would then have to ask Notepad++ to upgrade to the newer Scintilla.
However, you can add extra highlighting to a builtin lexer (like the bash/unix-shell lexer) using regexes via the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo. Those regexes wouldn’t be limited by the bash/unix-shell grammatical constraints, so if you defined a regex like\b(api|ssh|ansible)\b
, it would highlight those words under the scripts color definitions whenever they were found, not just in grammatically instruction-word locations.