Sublime Forum

Keyboard shortcut to copy the current line?

#1

Hi all. Is there a keyboard shortcut to copy the current line? If not, would it be possible to create one? If so, how would I approach that?

I realize there is a shortcut to cut an entire line. But I’d like one to merely copy the entire line.

Thanks in advance.

0 Likes

#2

You can press ctrl-L, ctrl-C.

3 Likes

#3

Great thanks–that should do.

0 Likes

#4

Note also this setting:

    // If true, the copy and cut commands will operate on the current line
    // when the selection is empty, rather than doing nothing.
    "copy_with_empty_selection": true,

When it’s turned on, not only does the cut operation grab the current line if nothing is selected, the copy command does as well. It’s turned on by default, so probably the standard copy shortcut will work for you if it works for cutting.

1 Like

#5

Ctrl-C works by itself to copy the entire line.

1 Like

#6

duplicate line:
ctrl + shift + d

2 Likes

#7

@OdatNurd @Jackeroo ok great, didn’t know that. It was already enabled, so I’ve begun using it now. Thanks!

0 Likes

#8

CTRL + L selects the entire line…

As for this - you can string together commands or create a macro of CTRL + L, CTRL + C and then bind it to a key so it’s 1 key… or a Control plus key combo, or anything really…

The Ctrl + L and Ctrl + C response is incredibly useful…

0 Likes

#9

OK thanks. But it seems there is already a default keybind set. See above. If nothing is selected, CTRL + C copies the entire line.

0 Likes

#10

Doesn’t work for me

0 Likes

#11

The copy_with_empty_selection setting has to be turned on for cut/copy to copy the current line with nothing selected. Perhaps you’ve turned that setting off.

0 Likes

#12

When nothing is selected.

0 Likes

#13

You can use this to quickly duplicate a line of code, place the cursor anywhere in the line and hit Cmd–Shift–D (Mac) or Ctrl–Shift–D (Windows).

Hope this will be help

0 Likes