How do you insert <br> or other HTML Tags into the document you're eiting?



  • How do you insert <br> or other HTML Tags into the document you’re eiting?



  • @Tom-Sims ,

    HTML tags, like <br>, are just text, and as such can just be typed in Notepad++.

    There may be a plugin that makes wrapping text with the HTML tags, but I don’t know which one. (There is an HTML Tag plugin in the Plugins Admin, but it appears focused on jumping-to-matching-tags, and doing HTML or JS entity encoding/decoding. Whether tag-insertion has been added to its feature list but just not in its brief overview is something I don’t know.)

    At one time, when I was doing more Markdown, I wrote up a series of scripts for the PythonScript plugin which would take the current selection and surround it witht he Markdown syntax for bold, italic, etc… and it’s possible to map those scripts to a keyboard shortcut – similar could be done with HTML syntax.

    Or easier than writing a script, and without the PythonScript, you could record macros which cut the currently-selected text, type the opening tag, paste the text, and type the closing tag (which, in effect, surrounds the currently-selected text with that chosen tag pair). And, like the script option above, the macros could be assigned to the keyboard shortcuts desired.

    (And the Customize Toolbar plugin would allow you to take either the script or macro solutions and add them as icons on the toolbar.)

    And then there are “code-snippet”-style plugins like QuickText, which allow you to define a text string, which you then follow with the “activation” keystroke, which will expand a short string into a much longer string, and easily allow you to move between fields inside that longer string – for example, the default for the img tag first expands into <img src="|" alt="|" />|, where the three | become the three “field” locations – so the first time you complete (hit the activation keystroke), it types the framework and moves your cursor to set the src value; hit the activation keystroke again and you will move to the alt-text, and a third time will take you after the image-tag so you can continue your normal HTML writing.

    What works for you will depend on your personal workflow, and the way you like doing things.

    If you have any specific questions on the techniques I listed, feel free to ask, and we can try to help. And maybe someone else will know of a plugin that already implements put-tags-around-or-into via buttons or keyboard shortcuts.



  • @PeterJones said in How do you insert <br> or other HTML Tags into the document you're eiting?:

    Or easier than writing a script, and without the PythonScript, you could record macros which cut the currently-selected text, type the opening tag, paste the text, and type the closing tag (which, in effect, surrounds the currently-selected text with that chosen tag pair). And, like the script option above, the macros could be assigned to the keyboard shortcuts desired.

    @Tom-Sims Expanding the fine @PeterJones’ advice, here is an example of a macro that inserts <br>selection<br>, which you can easily adapt to your needs.


Log in to reply