• Login
Community
  • Login

Select text via syntax highlighting

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
11 Posts 4 Posters 802 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.
  • D
    dfdeboer
    last edited by Aug 14, 2020, 4:52 PM

    In Notepad++ can I select text via syntax that has been highlighted? Example: Say I’m editing an html file. I hover my mouse over the"y" in a tag such as

    <a href=“https://mylink.htm ”>click here</a>

    and the whole URL, that is the whole text of “https/mylink.htm” gets automatically syntax highlighted by Notepad++. Can I now press a hot-key or right-click or something to select that entire URL? Or must I drag the mouse over the URL to select it?

    I ask because very often I need to select an entire syntactical element, say to copy it to some other location. Notepad++ is already aware of the element I’m after, yet I find myself tediously dragging the mouse from one endpoint of the element to the other and then right-clicking and clicking “copy” to select the element I’m after. It seems it could be easier and faster than that.

    A T 2 Replies Last reply Aug 14, 2020, 5:11 PM Reply Quote 0
    • A
      Alan Kilborn @dfdeboer
      last edited by Aug 14, 2020, 5:11 PM

      @dfdeboer said in Select text via syntax highlighting:

      Can I now press a hot-key or right-click or something to select that entire URL?

      No.

      Or must I drag the mouse over the URL to select it?

      Yes.

      Perhaps something could be done with scripting to ease this situation.
      URLs are done with indicator #8.
      Maybe a script with execution tied to a keycombo could be run when the URL is pointed at.

      A 1 Reply Last reply Aug 14, 2020, 5:28 PM Reply Quote 0
      • D
        dfdeboer
        last edited by Aug 14, 2020, 5:19 PM

        Thanks Alan! I thought it might be as you describe, but OTH if I was missing something it should would have been nice to figure it out.

        1 Reply Last reply Reply Quote 0
        • A
          astrosofista @Alan Kilborn
          last edited by astrosofista Aug 14, 2020, 5:29 PM Aug 14, 2020, 5:28 PM

          Hi @Alan-Kilborn, @dfdeboer

          As long as URLs are quoted strings, there is already a Pythonscript available and a macro solution as well. Take a look at

          Copying quoted strings

          Have fun!

          A 1 Reply Last reply Aug 14, 2020, 5:31 PM Reply Quote 3
          • A
            Alan Kilborn @astrosofista
            last edited by Aug 14, 2020, 5:31 PM

            @astrosofista said in Select text via syntax highlighting:

            As long as URLs are quoted strings, there is already a Pythonscript available and a macro solution as well

            Yea, makes sense.
            For the current thread I was thinking more of a hover-based solution.
            But clicking somewhere inside the text and then running the script/macro is pretty reasonable.

            1 Reply Last reply Reply Quote 0
            • D
              dfdeboer
              last edited by Aug 14, 2020, 7:22 PM

              Thanks astrosofista. I’ll probably try setting that up some day soon. (Must keep nose to grindstone and not get distracted by fun toys. . .)

              A 1 Reply Last reply Aug 15, 2020, 7:04 PM Reply Quote 0
              • A
                astrosofista @dfdeboer
                last edited by Aug 15, 2020, 7:04 PM

                Hi @dfdeboer

                You’re welcome. Glad to be of help.

                1 Reply Last reply Reply Quote 0
                • T
                  TroshinDV @dfdeboer
                  last edited by Aug 16, 2020, 4:35 AM

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • T
                    TroshinDV
                    last edited by Aug 16, 2020, 5:15 AM

                    I am using jN plugin for such task.
                    https://github.com/sieukrem/jn-npp-plugin
                    The “href” selection functionality is in the file:
                    https://github.com/trdm/jn-npp-scripts/blob/master/includes/IntellHtml.js

                    T 2 Replies Last reply Aug 16, 2020, 5:27 AM Reply Quote 0
                    • T
                      TroshinDV @TroshinDV
                      last edited by Aug 16, 2020, 5:27 AM

                      @Дмитрий-Трошин said in Select text via syntax highlighting:

                      I am using jN plugin for such task.
                      https://github.com/sieukrem/jn-npp-plugin
                      The “href” selection functionality is in the file:
                      https://github.com/trdm/jn-npp-scripts/blob/master/includes/IntellHtml.js

                      function htmlMakeSelections(psAnaliser) {
                      	var rv = '';
                      	if(0) {
                      		psAnaliser = new CHtmlTagAnalizer;
                          }
                      	if(psAnaliser) {
                      		//debugger;
                      		var vPosStart = -1, vPosEnd = -1, vAnchor = 0, vPosOffset = -1;
                      		
                      		var vTag = null, vLP = psAnaliser.getLastPlasement();
                      		if(vLP && htmlNeedSelections(vLP)) {		
                      	    	var vTag = vLP.tag;
                      			var vNames = ['img']
                      	    	if( vTag && vTag.name == 'img' && vLP.atribName == "src") {        
                      				// select 'img'  or "src
                          	        var vAtrName = vTag.atribByPos(vLP.column);
                      		        if (vAtrName != '') {
                      		            vPosStart = vTag.atribPosStartVal(vAtrName)+1;
                      		            vPosEnd = vTag.atribPosEnd(vAtrName);
                      					/* bytePos/Pos и column связаны, */
                      					vPosOffset = view.pos - view.column;
                      					view.anchor = vPosStart + vPosOffset;
                      					view.pos = vPosEnd + vPosOffset;
                      		        }
                      		    }		
                              }    
                          }
                      	return rv;
                      }
                      
                      
                      1 Reply Last reply Reply Quote 1
                      • T
                        TroshinDV @TroshinDV
                        last edited by TroshinDV Aug 16, 2020, 5:43 AM Aug 16, 2020, 5:42 AM

                        @Дмитрий-Трошин said in Select text via syntax highlighting:

                        I am using jN plugin for such task.
                        https://github.com/sieukrem/jn-npp-plugin
                        The “href” selection functionality is in the file:
                        https://github.com/trdm/jn-npp-scripts/blob/master/includes/IntellHtml.js

                        How it works.
                        ![alt text](image url)

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