Community
    • Login

    Selecting and tagging with custom tags

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.8k 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.
    • Brennan OBrienB
      Brennan OBrien
      last edited by

      Hey all – I’ve used N++ for years but never explored many of it’s deeper features, using it as a better find/replace in text files that default notepad.

      I’ve got a project I’m working on that I have a feeling N++ can handle, but I’m not sure how exactly.

      I have a set of custom tags I’m using for a project. What I want to be able to do is select portions of a text file, hit some key, and automatically add one of these tags to the start and end of the selected text. For example:

      If I were to select this text:

      lorem ipsum dolar sit amet
      

      and hit a defined key combination, the result I would get is this:

      <a>lorem ipsum dolar sit amet</a>
      

      Is there some way to do this in N++? If not, does anyone have thoughts on how I could do it?

      Thanks!

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

        @Brennan-OBrien ,

        Well, the easiest way is to install the HTML Tag Plugin, which has buttons which do just that.

        But if you’re really thinking about the generic procedure, rather than the <a>...</a> wrapping specifically, you could record a macro:

        1. Select Text
        2. Macro > Start Recording
        3. Cut (Ctrl+X or menu equivalent)
        4. type <a>
        5. paste (Ctrl+V or menu equivalent)
        6. type </a>
        7. Macro > Stop Recording
        8. Macro > Save Current Recorded Macro
          • optionally assign a keyboard shortcut that you will remember.

        From then on, using that macro (from the Macro menu or from the keyboard shortcut) will place the selected text between <a>...</a>. Since the macro is saved in shortcuts.xml, it will still be available the next time your run Notepad++.

        (Please note that this macro does clobber your current clipboard contents; if this bothers you, using the HTML Tag plugin will be better)

        • Online UserManual: Macro Overview: https://npp-user-manual.org/docs/macros/
        • Online UserManual: shortcuts.xml macro syntax: https://npp-user-manual.org/docs/config-files/#macros
        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors