Copy entire line without selecting it?

  • Many IDE’s have this feature that if you don’t select any characters, copying (menu or CTR-C) will copy the entire line the cursor happens to be on, from start to line feed (included). Is there a way to do that or an extension to enable that in Notepad++?

  • @Martin-Pelletier

    There isn’t a true built-in way, but there are a number of methods for achieving that functionality, some of which are discussed here.

    My personal favorite way is via a Pythonscript that flashes the entire line briefly as feedback that the copy actually happened.

  • @Martin-Pelletier
    I would also recommend PythonScript plugin.
    You’ll just need a two-line script to achieve this:

    myline = editor.getCurLine()

    That’s it. The current line (where the caret is) will be
    copied into clipboard. Then bind your favourite key to run this and done.

  • @Martin-Pelletier

    didn’t check when it has been added but the most recent versions do have it and
    it is mapped to CTRL+SHIFT+X in default configuration.

    Check shortcut mapper, scintilla commands - the message you are looking for is
    SCI_LINECOPY (row 92 for me).


  • @Claudia-Frank

    I think a key point is that people expect this functionality on ctrl+c (or ctrl+x for “cut current line if no selection”)…they don’t want to have to remember a separate key combo for these special cases of copy/cut. Even when accepting of a separate keycombo, the default of ctrl+shift+x is horrible for the ‘copy’ variant, IMO.

  • @Mikhail-V

    Your Pythonscript also requires a separate keycombo for the functionality versus the normal copy function. Something like the following short script, mapped to ctrl+c (remove the default Scintilla ctrl+c assignment!), might be better as the user gets normal copy-selection capability plus (unselected) current line copy capability…without having to think about what they are doing (just hit ctrl+c!):

    if len(editor.getSelText()) > 0:

  • CTRL+SHIFT+X copies the current line without having to select it.

    You can find it in shortcut mapper - scintilla commands tab - SCI_LINECOPY

  • My similar question is "How to Delete entire current line (appearing multiline with word-wrap on) without selecting it first?

  • @V-S-Rawat

    CTRL+SHIFT+L (row 90 - standard configuration)


  • @Mikhail-V

    Why is the script any more complicated than this one line?
    Replace the default Control-C mapped command with a pointer to that Pythonscript and that is all it takes. Unless I’m missing a key point…

  • With 5 “likes” I guess I didn’t miss the point!

  • I’ve always liked the cutting/copying of entire lines like Visual Studio has (I’m sure many other editors/IDEs have it as well). There are at least 2 plugins available through the PluginManager that adds this functionality to N++. Myself, I’ve been using the following LuaScript for quite a while. I’m sure this logic could be easily adapted to be used in PythonScript as well:

    -- Mimic Visual Studio's "Ctrl+C" that copies the entire line if nothing is selected
    npp.AddShortcut("Copy Allow Line", "Ctrl+C", function()
    -- Mimic Visual Studio's "Ctrl+X" that cuts the line if nothing is selected
    npp.AddShortcut("Cut Allow Line", "Ctrl+X", function()
        if editor.SelectionEmpty then

  • @dail

    Yes. Since the PythonScript “copy” case has already been beaten to death in this thread, but the PS “cut” case maybe hasn’t been, here’s the port of your LuaScript for that:

    if editor.getSelectionEmpty():

    A fairly direct port! :-D

    Unfortunately, in PS shortcut-mapping isn’t as easy to do as it is in LS.

Log in to reply