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

前端 未结 8 691
孤街浪徒
孤街浪徒 2021-02-02 10:33

I\'m using Notepad++ for some projects and miss Visual Studio\'s Ctrl + X, Ctrl + C functionality that cuts or copies the entire curr

8条回答
  •  我在风中等你
    2021-02-02 11:04

    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

提交回复
热议问题