Community
    • Login

    autocomplete for complex svg tag

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    svg tagautocomplete sv
    6 Posts 2 Posters 1.1k 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.
    • Adriano ElleroA
      Adriano Ellero
      last edited by

      I tried to edit html.xml file within autoCompletion folder
      I can add new tags like <KeyWord name=“rectNew” />
      I want to write SVG tags faster including entire tag attributes that are often the same.
      But I can’t add attributes to my tag.
      I would expect that works like this:
      <KeyWord name="rect x=‘0’ y=‘0’ " />
      but it does not!
      empty space works splitting the entire tags in different part of it. I can find x=0 in the option list but not autocompleted as wanted at once.

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        Per the other thread you posted in minutes before this post, spaces in the autocomplete file haven’t worked since v6.5.3.

        That other thread gave a workaround, which is to embed some other character, and then after auto-completion is done, replace that other character with the space.

        For example, I added

                <KeyWord name="rect&#xa0;nxa0x=0&#xa0;nxa0y=0" />
        

        to my autoCompletion\html.xml file, where &#xa0; is the numerical entity for the non-breaking space.

        When I reloaded and typed rect, the auto-complete popdown shows rect x=0 y=0 – but those space-like characters are really non-breaking spaces. Since the resulting SVG will not work with non-breaking spaces, you can then do a search/replace regex with Find=\xa0 (non-breaking space in regex character escape), Replace=\x20 (space in regex character escape)

        1 Reply Last reply Reply Quote 1
        • Adriano ElleroA
          Adriano Ellero
          last edited by

          thx Peter
          it sounds to me really dirty… other options?

          1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones
            last edited by PeterJones

            If that two-step process seems dirty to you, I am not sure I’d be able to recommend a process that would be “clean” in your opinion. But there are more ways to accomplish the same task, though not using the Auto-Completion feature of Notepad++ as it’s currently implemented

            1. record a macro using the Macro menu: that macro would involve you typing the sequence, and saving it to a keystroke

              1. place the cursor where you want
              2. Macro > Start Recording
              3. type rect x=0 y=0
              4. Macro > Stop Recording
              5. Macro > Save Current Recorded Macro, then give it a name and keyboard shortcut
              6. in the future, use that keyboard shortcut to insert the rect x=0 y=0
            2. Write your own plugin or PythonScript to help you automate frequent sequences that don’t work in auto-complete; for example, maybe have the Python script look for some special prefix (maybe \|) before at least 4 alphanumeric characters, and if it sees that, have it pop up your own auto-complete chooser based on those 4 characters: for example, maybe typing \|rect would pop-up your chooser, then replace \|rect with rect x=0 y=0 after you selected it from the dropdown.

            3. submit a feature request, per the feature-request/bug-report FAQ, which points to both the original thread and your duplicate thread here, and explains in clear words with examples what feature you want, and then be prepared to wait, and be willing to use a workaround in the mean time (because there is no guarantee of the feature being implemented, let alone being implemented in a quick turnaround time).

            1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones
              last edited by

              1. A combo of my original search-and-replace suggestion and the first half of suggestion #2: use PythonScript to define a callback on the SAVE event, where PythonScript would then do a search-and-replace for all \xa0 characters and replace them with \x20 (space) characters. That way, you could use the auto-complete as implemented, but have PythonScript “remember” to do the replace for you every time that you save.

              I think #1 would be the easiest if you’re going to have just that one sequence with spaces. #4 will be easier if you have multiple space-containing sequences you want to autocomplete.

              1 Reply Last reply Reply Quote 1
              • Adriano ElleroA
                Adriano Ellero
                last edited by

                Thanks a lot Peter, I tried Macro also and I found it simple and “clean enough”…

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