• Login
Community
  • Login

After TAB scriptblock error

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 3 Posters 461 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.
  • V
    Venus642
    last edited by Jan 24, 2022, 6:50 AM

    Hi all.
    I have a simple question:

    Example:
    error.jpg

    What can you do if you want to use the TAB to indent the code?
    Thanks for yur help.

    M 1 Reply Last reply Jan 24, 2022, 1:20 PM Reply Quote 0
    • A
      Alan Kilborn
      last edited by Jan 24, 2022, 1:11 PM

      Well you would go to the Settings menu and choose Preferences… and then see:

      1b6845c3-186b-47c2-9938-cbc062ee0b81-image.png

      And you would change the setting for the language of interest (maybe what you show is Perl?).

      1 Reply Last reply Reply Quote 0
      • M
        mpheath @Venus642
        last edited by Jan 24, 2022, 1:20 PM

        @venus642

        Looks to be the Powershell language.

        Quote from Microsofts Powershell about_Quoting_Rules documentation on Here-strings.

        In either format, the closing quotation mark must be the first character in the line.

        So it appears that "@ needs to be at the start of the line to be valid syntax.

        Powershell Here-strings are not designed for indenting. So you may need to break the implied rule of indenting by:

        function test1
        {
        $test = @"
        This is a test
        "@
        }
        
        	function test2
        	{
        	$test = @"
        This is a test
        "@
        	}
        

        Looks ugly though it is valid syntax.

        V 1 Reply Last reply Jan 24, 2022, 1:33 PM Reply Quote 2
        • V
          Venus642 @mpheath
          last edited by Jan 24, 2022, 1:33 PM

          @mpheath said in After TAB scriptblock error:

          Looks to be the Powershell language.
          Quote from Microsofts Powershell about_Quoting_Rules documentation on Here-strings.

          In either format, the closing quotation mark must be the first character in the line.

          So it appears that "@ needs to be at the start of the line to be valid syntax.
          Powershell Here-strings are not designed for indenting. So you may need to break the implied rule of indenting by:

          error.jpg

          Yes, powershell problem…
          Yes ugly, I would like it to be fully indented…

          V 1 Reply Last reply Jan 24, 2022, 1:40 PM Reply Quote 0
          • V
            Venus642 @Venus642
            last edited by Venus642 Jan 24, 2022, 1:42 PM Jan 24, 2022, 1:40 PM

            @venus642
            error1.jpg
            Not so nice …

            V 2 Replies Last reply Jan 24, 2022, 1:44 PM Reply Quote 0
            • V
              Venus642 @Venus642
              last edited by Jan 24, 2022, 1:44 PM

              @venus642

              It would be nice if Notepad++ could handle that.

              M 1 Reply Last reply Jan 24, 2022, 1:58 PM Reply Quote 0
              • M
                mpheath @Venus642
                last edited by Jan 24, 2022, 1:58 PM

                @venus642 said in After TAB scriptblock error:

                @venus642

                It would be nice if Notepad++ could handle that.

                It is Powershell syntax. Notepad++ cannot do anything about how Powershell works.

                The Lexilla component code is:

                		} else if (sc.state == SCE_POWERSHELL_HERE_STRING) {
                			// This is a doubles quotes here-string
                			if (sc.atLineStart && sc.ch == '\"' && sc.chNext == '@') {
                				sc.Forward(2);
                				sc.SetState(SCE_POWERSHELL_DEFAULT);
                			}
                

                sc.atLineStart is a condition to close the Here-string, it must be at the start of the line. It complies with the current syntax of Powershell.

                If you want change to support indentation of Here-strings, then Powershell core development is where the change needs to done.

                V 1 Reply Last reply Jan 24, 2022, 2:02 PM Reply Quote 3
                • V
                  Venus642 @mpheath
                  last edited by Jan 24, 2022, 2:02 PM

                  @mpheath
                  Thanks mpheath for your help and info.

                  1 Reply Last reply Reply Quote 0
                  • V
                    Venus642 @Venus642
                    last edited by Jan 25, 2022, 4:24 PM

                    @venus642

                    WARNING !
                    Had to realize that errors can occur when indenting. So it’s best to avoid it.

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