• Login
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.
  • B
    Brennan OBrien
    last edited by Oct 24, 2022, 1:55 PM

    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!

    P 1 Reply Last reply Oct 24, 2022, 2:06 PM Reply Quote 0
    • P
      PeterJones @Brennan OBrien
      last edited by Oct 24, 2022, 2:06 PM

      @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
      2 out of 2
      • First post
        2/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors