Community
    • Login

    Selecting and tagging with custom tags

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.7k Views 2 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors