autocomplete for complex svg tag



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



  • 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)



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



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



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


Log in to reply