Automatically apply style token when highlighting text?



  • I use notepad++ when copying from configuration files to apply to network equipment. The issue is, sometimes sections get left off and there’s no way to tell if it’s been copied or not. Is there a way to setup notepad++ to automatically apply a style token each time text is highlighted/copied?



  • @mclyburn5

    That’s an intriguing idea. It is nothing that Notepad++ can do natively, but if you’re willing to use the PythonScript plugin, I’ll volunteer to write a script that can do it for you – there’s not much to it.

    EDIT: Hmmm, maybe even a macro could do it…



  • Yep, a macro can do it. Steps to set it up:

    • Start with some selected text
    • Start macro recording (see Macro menu)
    • Go to the Search menu, and pick your style choice from the Mark All submenu
    • Press Ctrl+c
    • Stop macro recording (see Macro menu)
    • Save the macro (see Macro menu) with a name
    • Assign the macro to a keycombo (see Settings menu then Shortcut Mapper…)

    Now, anytime you want to do the action, after selecting some text, run the macro via the keycombo to both stylize the text and copy it to the clipboard.



  • Hey they works great! Is there a easy way to share this macro with other team members?



  • @mclyburn5

    Not super easy, but it is stored in shortcuts.xml file so you could textually copy out of there.

    But…why not just share the short instruction list on how to set it up. That by far is the easiest unless we’re talking about dozens/hundreds/thousands of users.



  • @Alan-Kilborn Yeah the issue is a lot of the folks I’d be sharing it with aren’t the most technically savvy. They basically just copy/paste all day. I’d like to be able to just send a file that they can load themselves and be done with it.



  • @mclyburn5

    Well, I understand, but unfortunately the shortcuts.xml file contains more than just what you created with the instructions above. You could distribute it, but if anyone you distributed it to had customized Notepad++ as far as keycombos or other macros goes, it would blow away such setups.

    But if you still think it is OK, then you need to:

    • shut down your Notepad++ (to get shortcuts.xml to be saved)
    • locate that file (perhaps most likely found in the APPDATA area, but this is not a 100% certainty)
    • distribute that file to the others
    • have others exit their Notepad++
    • copy the file to the correct place (again, likely “APPDATA”)

    So to me, THAT may be more complicated than just the macro recording thing I discussed earlier. But, it is your choice.



  • Another method is to copy only the lines pertaining to the macro out of your shortcuts.xml and have your users put those same lines in theirs. I neglected to mention this, because, for unsophisticated users, this is probably the MOST complicated and error-prone approach.


Log in to reply