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.

TL;DR - How can I enable virtual spaces to move the cursor past the end of a line of text?

Long version - In Notepad++, when trying to select (using the mouse) a long line of text that extends past the right edge of the window, causing it to scroll horizontally, my mouse will sometimes go slightly up or down enough to move the cursor to the adjacent (usually much shorter) line, causing the cursor to snap back to the left where that adjacent line ends; which in turn scrolls the window horizontally back to the left, making it difficult to quickly readjust and finish dragging out my selection.

Some (though woefully few) text editors have an option for "virtual spaces", or cursoring past the EOL, to make it much easier to mouse/arrow around without being restricted to existing text/whitespace.

How can I make this happen in Notepad++ (without hacking the source myself)?

share|improve this question
1  
start of line, hold SHIFT + END, have the whole line selected? I know it's not the same as what you wanted, but it's what I do. –  Rob Mar 16 '12 at 17:50
1  
Not what you ask, but the problem would go away with line wrapping. –  Eroen Mar 16 '12 at 17:55
    
@Rob: This is generally an issue when I'm trying to select a specific long chunk of a very long line of code, but that line is intermingled with other much shorter lines. I could also use SHIFT + CTRL + RIGHTARROW to quickly select rightward from my starting point one word at a time, Notepad++ is pretty good at detecting word-break characters such as periods, parentheses, etc. when there aren't any actual spaces separating words (such as in a long object reference) e.g. (javascript): someObjectName.subObject.property['index'](parameter) –  acatalept Mar 16 '12 at 18:00
    
@Eroen: glad you suggested this, I haven't used word-wrap in N++ for a long time, as it used to bring the program to its knees with large files... but it actually works very nicely even for my bigger 20k line files, and even lines up indents on wrapped lines ;) –  acatalept Mar 16 '12 at 18:05

1 Answer 1

up vote 4 down vote accepted

Sort of a hack (sends a window message directly to the Scintilla edit control on startup), but works great:

  1. Install NppExec plugin

  2. Go to Plugins -> NppExec -> Execute

  3. Enter the following code:

    // ensure console stays hidden
    NPP_CONSOLE 0
    
    // enable virtual spaces (cursor past end of line) outside column edit mode
    SCI_SENDMSG 2596 3 0
    
    // SCI_SENDMSG == send message to Scintilla edit control
    // 2596 == the message we're sending is SCI_SETVIRTUALSPACEOPTIONS
    // 3 == send the value (SCVS_RECTANGULARSELECTION | SCVS_USERACCESSIBLE)
    // the default value is 1 (just SCVS_RECTANGULARSELECTION) for
    //   virtual spaces in column select mode only
    // you can find these values by poking around the source code a bit, or
    // see http://www.scintilla.org/ScintillaDoc.html
    
  4. Click the Save button at the bottom, and give the script a name

  5. Now go to Plugins -> NppExec -> Advanced Options

  6. On the right, under "Execute this script when Notepad++ starts", select the script name you just saved

  7. Click OK, close/reopen Notepad++, and enjoy ;)

share|improve this answer
    
Just found this from Google. Works! Awesome, thanks! –  Tzvetan Mikov Aug 15 '12 at 19:23
    
where are message codes like 2596 documented for other scintilla commands? poking Scintilla.h only? currently at tortoisesvn.googlecode.com/svn/trunk/ext/scintilla/include/… ? –  naxa Dec 21 '12 at 8:07
    
What is 0 in SCI_SENDMSG 2596 3 0 ? –  naxa Dec 21 '12 at 8:10
    
@naxa: see the Scintilla documentation for the message codes, e.g. scintilla.org/ScintillaDoc.html#SCI_SETVIRTUALSPACEOPTIONS (I believe the 3rd parameter is unused for most of these, but must be set to 0 rather than omitted) –  acatalept Dec 21 '12 at 16:29
    
"Sort of a hack" - a hack means accessing something that the software was not supposed to do. This looks like a feature to me. –  Nathan Adams Dec 21 '12 at 16:37

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.