Keyboard shortcut for duplicate line was changed in new design editor and that makes me sad.

SOLVE
keegan-sbm
Contributor

In the old code editor, the CMD+D command used to duplicate the current line, and now it just deletes it. This was a super usefult shortcut. Deleting a line is not super useful.

 

I'm sad now. Is there anything that can make me unsad?

0 Upvotes
1 Accepted solution

Accepted Solutions
keegan-sbm
Solution
Contributor
CodeMirror.keyMap.macDefault["Cmd-D"] = function(cm){
    var current_cursor = cm.doc.getCursor();
    var line_content = cm.doc.getLine(current_cursor.line);
    CodeMirror.commands.goLineEnd(cm);
    CodeMirror.commands.newlineAndIndent(cm);
    CodeMirror.commands.goLineLeft(cm);
    cm.doc.replaceSelection(line_content);
    cm.doc.setCursor(current_cursor.line + 1, current_cursor.ch);
};

Running ^ from the chrome console brings back duplicate line functionality to CMD+D.

View solution in original post

7 Replies 7
tjoyce
Recognized Expert | Platinum Partner

CMD+SHIFT+D

(now you're unsad) 😄

0 Upvotes
keegan-sbm
Contributor

I want to believe that's working for somebody. For me (in chrome) that's just causing the bookmarks dialogue to pop up. Cest la vie. Thanks for trying though.

0 Upvotes
tjoyce
Recognized Expert | Platinum Partner

The bookmark does appear if I'm not "focused" in the editor, but once I click on any code in the editor, the duplicate works. Not sure if that helps your scenario.

0 Upvotes
keegan-sbm
Contributor

Tried a couple variations to no avail, although maybe its an issue of too many hubspot tabs open or stale session or something. I bet this is something a crafty bookmarklet could fix.

keegan-sbm
Solution
Contributor
CodeMirror.keyMap.macDefault["Cmd-D"] = function(cm){
    var current_cursor = cm.doc.getCursor();
    var line_content = cm.doc.getLine(current_cursor.line);
    CodeMirror.commands.goLineEnd(cm);
    CodeMirror.commands.newlineAndIndent(cm);
    CodeMirror.commands.goLineLeft(cm);
    cm.doc.replaceSelection(line_content);
    cm.doc.setCursor(current_cursor.line + 1, current_cursor.ch);
};

Running ^ from the chrome console brings back duplicate line functionality to CMD+D.

View solution in original post

tjoyce
Recognized Expert | Platinum Partner

Yep, you're right, this is from their project bundle - (no duplicate) 

nodups.png

 

Also, found this in the source code, kinda funny 😄

fired.png

keegan-sbm
Contributor

rofl

0 Upvotes