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

前端 未结 8 542
孤街浪徒
孤街浪徒 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 10:44

    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.

    0 讨论(0)
  • 2021-02-02 10:51

    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)

    0 讨论(0)
  • 2021-02-02 10:52

    There is a plugin for it at https://github.com/kbilsted/NppPluginCutNCopyLine its open source and the code is easy to modify if you have extra needs.

    0 讨论(0)
  • 2021-02-02 10:54

    The plugin from MackieChan: notepad-visual studio line copy

    has to be still setup-ed as follow:

    1. Put it into notepad++/plugin folder

    2. open notepad++ (restart)

    3. in Settings -> Shortcut Mapper

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

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

    0 讨论(0)
  • 2021-02-02 10:55
    1. Install NppPython plugin (can be done with Notepad++ Plugin Manager)
    2. Create this python script using the menu Plugins -> Python Script -> New script:

      if editor.getSelectionStart() == editor.getSelectionEnd():
          editor.lineCut()
      else:
          editor.cut()
      
    3. Restart notepad++ (important)

    4. Go to Menu Settings -> Shortcut Mapper -> Plugin commands

    5. Find the script you just created in the list and set CTRL+X shortcut for it

    6. Enjoy!

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题