Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am doing some langauge translations of an old HTML website so I am just pasting the new translations from a Word document into the old files.

So I have to select everything between the tags (h2, p, li, etc.) and then paste the new text in – from a Word file. For selecting everything in between p tags I have to select one side of the inside tag, then hold Shift, then select the next side to highlight everything... my fingers are getting really tired, and I got 40 files (pages) total with 3 languages to do.

Is there a shortcut in Notepad++ to select everything between two tags (excluding the tags; like when you double click a word it selects the whole word).

<p>This is some English that needs to be translated here. 
I want to just click in this area to select all of this 
text between these two paragraph tags.</p>
<p>This would be another block of translation to do</p>
<ul>
    <li>I want to click here and select everything between the li tags</li>
</ul>
share|improve this question

4 Answers 4

up vote 4 down vote accepted

Direct answer:: No.

Can it be made? Yes.
Simply? Yes.
Into a single shortcut? Yes

What's needed? N++ PythonScript and HTML Tag plugins.

Why? We are going to use the HTML Tag's Select Tag and Contents from a python script that will adjust the selection made by HTML Tag by moving the start to just after the first '>' and the end to just before the last '<'.

After installing the N++ PythonScript plugin create a new script with this code::

# Reduce selection to omit the outer most tags selected by the 'HTML Tag' plugin.

from Npp import *

def omit_tag( args ):
    editor.clearCallbacks()
    SelText = editor.getSelText()

    if SelText:
        orig_Start = editor.getSelectionStart()
        new_Start = orig_Start + SelText.find(">")

        orig_End = editor.getSelectionEnd()
        new_End = orig_Start + SelText.rfind("<")

        if new_Start > orig_Start and new_End < orig_End:
            editor.setSel( new_Start + 1, new_End )

def main():
    editor.callback( omit_tag, [SCINTILLANOTIFICATION.UPDATEUI] )
    notepad.runMenuCommand("HTML Tag", "Select Tag and Contents")

main()

After creating the script, use the PythonScript configuration dialog to add the script to the 'Menu Items' list (which will allow us to assign the shortcut). Restart, then use the Settings->Shortcut Mapper::Plugins dialog, add a Shift+Alt+T shoftcut to the new entry for the script you just created. Restart again to write out the new shortcut entry the N++ config.

So now (using your sample text), from the line where you wanted to click::

CTRL+T to jump to the other tag.
CTRL+Shift+T to select the whole tag block.
Shift+Alt+T to select the inner text.

If you attempt to select the 'content' portion of the block you'll notice the line endings are captured too. This could be seen as either a plus or minus depending on your viewpoint...

One recommendation, make use of SCI_SWAPMAINANCHORCARET to allow you to adjust either end of your selection using the normal movement and selection modifiers. You can set it from the shortcut mapper on the Scintilla panel (near the bottom). I've set mine to CTRL+Shift. which works great, since when already modifying a selection Shift is usually already pressed.

Hopefully that helps. Have fun!

share|improve this answer

I would use the "Fold All" (Alt-0) feature so every paragraph is displayed as a seperate line. In Word I would add <p> at the beginning of every line and </p> at the end of every line and then overwrite complete lines using Shift-Down to select a line and Ctrl-V to paste the translated line from Word. Unfold All (Alt-Shift-0) unfolds everything once you are done.

share|improve this answer

This task of selecting text between tags can be accomplished without scripts, but not in Notepad++.

If you install SynWrite editor, just call command Search -- Select current token and text between tags is selected.

share|improve this answer

if plugin install do not bother you, I highly recommend to install HTML Tag, especialy if you are an html eater.

Once setup, just ctrl+shift+t with cursor on the opening or closing tag

share|improve this answer
    
Please see How do I recommend software in my answers? –  G-Man Sep 4 at 15:51
    
+1 for this answer. It worked for me( ctrl+shift+t with cursor on the opening or closing tag) –  RN Kushwaha Sep 8 at 13:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.