• Login
Community
  • Login

settings--preference--language style setting--bash--instruction word,is the keywords has number or word limit?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 1.4k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L
    ljhmily
    last edited by Dec 23, 2020, 2:07 AM

    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.

    1 Reply Last reply Reply Quote 0
    • T
      Terry R
      last edited by Terry R Dec 23, 2020, 2:17 AM Dec 23, 2020, 2:16 AM

      @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

      L 1 Reply Last reply Dec 23, 2020, 2:34 AM Reply Quote 1
      • L
        ljhmily @Terry R
        last edited by Dec 23, 2020, 2:34 AM

        @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.

        T P 2 Replies Last reply Dec 23, 2020, 2:41 AM Reply Quote 0
        • T
          Terry R @ljhmily
          last edited by Dec 23, 2020, 2:41 AM

          @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

          1 Reply Last reply Reply Quote 1
          • T
            Terry R
            last edited by Terry R Dec 23, 2020, 2:48 AM Dec 23, 2020, 2:47 AM

            @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

            L 1 Reply Last reply Dec 23, 2020, 3:06 AM Reply Quote 1
            • L
              ljhmily @Terry R
              last edited by Dec 23, 2020, 3:06 AM

              @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.

              1 Reply Last reply Reply Quote 0
              • P
                PeterJones @ljhmily
                last edited by Dec 23, 2020, 2:18 PM

                @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 and wget 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:

                d5b9e1be-2492-4aca-a09c-f6d917a84620-image.png

                cat api only marks cat as a keyword because in the grammar of bash, cat is in the location of a command, but api is not (it’s the argument, not the instruction). But api blah at the beginning of the line will allow api 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
                edec2c4f-2917-4462-b8a3-0e881bd569c9-image.png
                should highlight the ls as well as the ssh, because ls 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, and copy as arguments, not as instructions, so only the ansible 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.

                1 Reply Last reply Reply Quote 3
                4 out of 7
                • First post
                  4/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors