Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mimic Visual Studio's CTRL-X, CTRL-V functionality in Notepad++?

Tags:

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.

like image 672
eft Avatar asked Mar 06 '09 17:03

eft


People also ask

What is the shortcut code for Visual Studio code?

use shortcut Ctrl + Alt + M. or press F1 and then select/type Stop Code Run.

How do I add keyboard shortcuts to Visual Studio?

On the menu bar, choose Tools > Options. Expand Environment, and then choose Keyboard. Optional: Filter the list of commands by entering all or part of the name of the command, without spaces, in the Show commands containing box. In the list, choose the command to which you want to assign a keyboard shortcut.


2 Answers

I've created a Notepad++ plugin that does this (without the need of python). It can be found at https://bitbucket.org/zastrowm/notepad-visualstudiolinecopy.

like image 186
zastrowm Avatar answered Oct 16 '22 03:10

zastrowm


Synthesizing all other answers and comments, plus some additional necessary steps that haven't been mentioned:

Scintilla provides a "copyAllowLine" command that does this. Notepad++ doesn't expose that command in the shortcut mapper, but you can call it from a Python script and map Ctrl + C to that script. There is no corresponding command for "cutAllowLine", but a bit of extra Python code will do it. These scripts must be added to the menu and Notepad++ must restart before they will become available in the shortcut mapper.

  1. Install Python Script plugin(can be done with Notepad++ Plugin Manager)

  2. Create the following two python scripts using the menu Plugins -> Python Script -> New script

    copyAllowLine.py

    editor.copyAllowLine() 


    cutAllowLine.py

    if editor.getSelectionStart() == editor.getSelectionEnd():     editor.lineCut() else:     editor.cut() 


  3. Python Script -> Configuration

    • under User Scripts, add a menu item for each script.

  4. Restart notepad++ (important)

  5. Settings -> Shortcut Mapper...

    • under Scintilla Commands, remove the existing associations for Ctrl + C and Ctrl + X.

    • under Plugin commands, find the scripts you just created and map your shortcuts to them.

Note: when installed via plugin manager, version 1.0.6 was installed. When I attempted to run anything python related in Notepad++ I got an unknown exception from plugin manager. The solution was to manually download and install the 1.0.8 .msi from here: 1.0.8 installer

like image 40
Andrew Lundin Avatar answered Oct 16 '22 02:10

Andrew Lundin