views:

416

answers:

3

I'm using Notepad++ for some projects and miss Visual Studio's CTRL-X, CTRL-C functionality that cuts or copies the entire current line when no text is selected. The cut line shortcut seems to be CTRL-L, which is not as convenient as CTRL-X and the copy shortcut seems to be CTRL-D, CTRL-L, which is even less convenient.

Although a similar question has been asked before, the way to do this in Notepad++ was not provided and I cannot find a solution on the Notepad++ site or on its forums.

+1  A: 

Go to Settings->Shortcut Mapper and click on the "Scintilla commands" tab at the top. Under there you should be able to change the CTRL-L command to CTRL-X.

MPiccinato
Thanks but that doesn't seem to work. Maybe it cannot overload the two maps for CTRL-X. Do you have to remap CTRL-X as well?
eft
I just tried it with removing CTRL-X from the CUT command and adding it to only the CUT LINE command, give that a try.
MPiccinato
Thanks again, but then what happens is that the CTRL-X will delete the entire line, even if text is selected. These are seemingly small differences but when you do the operation hundreds of times a session it adds up.
eft
I see what you are saying, I can't find a way to mimic this functionality exactly with just using the options. Sorry :(
MPiccinato
Well, I appreciate your assistance and for pointing out the Scintilla commands. Thanks!
eft
A: 

you can write a program with a global key event hook, which every time you make a "CTRL+X" checks if notepad++ is the foremost application running, grabs the screen, checks if any text is selected (by looking at the screenshot and your notepad++ color settings), and sends a WM_KEYPRESS message to the notepad++ window simulating a CTRL+L (assuming you're using windows).

(this won't put the line into the clipboard though, you'll have to make some character recognition to allow it)

A: 

You can add a script with the Python Script Notepad++ plugin, and assign Ctrl-C to the script (remove the Ctrl-C mapping from SCI_COPY in shortcut mapper, Scintilla Commands tab)

The script is just:

if editor.getSelectionStart() == editor.getSelectionEnd():
    line = editor.getCurLine()
    editor.copyText(line)
else:
    editor.copy()

Obviously just add another similar script for Ctrl-X that removes the line instead.

Dave Brotherstone
It's just been pointed out that Scintilla supports it directly, so you can use editor.copyAllowLine()
Dave Brotherstone