Sublime Forum

Duplicate not working

#1

Hi,

I am having problem with Ctl + Shift + D shortcut in windows; its not working in my sublime text 3.

Please help!

0 Likes

#2

Duplicate lines doesn’t work for selections that span across multiple lines. Does it work if you press ctrl+shift+d with an empty selection?

Edit: sorry my mistake

0 Likes

#3

It does work for multiple lines here.

@touhid_rahman,

  1. Which is the version of Sublime Text and Operating System do you use?
  2. Can you reproduce it after reverting Sublime Text
0 Likes

#4

It’s not working even for single line: http://prntscr.com/hj6l7p

  1. Sublime Text 3, Build 3143 and my computer is Windows 8.1 Pro
  2. Done, I have re-installed several times just for this option.
0 Likes

#5

Reinstalling Sublime Text has not effect upon a corrupted package or settings on your user files. You need to revert it to a clean state: https://www.sublimetext.com/docs/3/revert.html

If it still not working, even after reversing it to a clean state, it could mean some program on you computer is stealing the Sublime Text keystroke Ctrl+Shift+D. You can know it by opening Sublime Text console by going on the menu View -> Show Console. Then you can use these commands to enable/disable the logging/debugging:

sublime.log_input(True); sublime.log_commands(True); sublime.log_result_regex(True)
sublime.log_input(False); sublime.log_commands(False); sublime.log_result_regex(False)

What do you see on the Sublime Text console after enabling the debug/logging and pressing the Ctrl+Shift+D key binding?

0 Likes

#6

I am using portable Sublime Text right now, I can’t find the folder in location mentioned in that page. Please help…

I am getting this message when using in view > console

0 Likes

#7

You can find that folder just by going on the menu Preferences -> Browse Packages...

From you screenshot, I see that you successfully enabled debug/log mode. Now you need to press the key bind Ctrl+Shift+D on some code line and see what outputs on the Sublime Text console. This is what happens here:

You should be able to see that:

key evt: shift+control+d
command: duplicate_line

If you do not see it, it means there is some other application/program on your computer stealing Sublime Text keystroke Ctrl+Shift+D. Then there nothing we can do to help. You need to find out which application is this, and kill it. Or change the duplicate line keybind to some other keystroke available.

0 Likes

#8

The console shows everything but nothing happens when I hit shift+control+d
I have closed all other programs… still not happening

Can you please tell me how can I assign a new key stroke combination for the duplicate option?

0 Likes

#9

But fist you need to find out some available keystroke on you keyboard. You can see the console log when you press the keystroke.

If the Sublime Text console show the keys like this:

key evt: shift+control+s

after the keystroke, it means these keys are available for use by Sublime Text. Now you can:

  1. Go to the menu Preferences -> Key Bindings
  2. Then on the right side panel, you can add this:
[
    { "keys": ["ctrl+shift+s"], "command": "duplicate_line" },
]

It would set the duplicate line keybind to the keystroke Ctrl+Shit+S.

You can add multiple new keybinds, just by adding new lines to the file like this:

[
    { "keys": ["ctrl+shift+s"], "command": "duplicate_line" },
    { "keys": ["ctrl+j"], "command": "join_lines" },
]

Once you save the file, the changes will take effect immediately.

1 Like

#10

Thanks a lot, I changed keystroke to ctl+d; its working perfectly :slight_smile:

1 Like