Duplicate Line(s) Keyboard Shortcut

I humbly submit cmd + shift + D as a keyboard shortcut to duplicate the current line, or the currently selected lines. This is a code editor shortcut that comes in handy for me when taking notes.

Any other variant would work. I’d prefer cmd + D, but as I’ve discovered that’s a command to delete the current line.

Thanks to the Obsidian team!

31 Likes

If you have a macro software, you could just do this with a macro. E.g., with Keyboard Maestro on the Mac:

2 Likes

That’s great until I need to use Obsidian on another computer. It would be nice to know that, out of the box, wherever I want to use it, Obsidian has a keybinding for duplicating lines.

3 Likes

There’s already Vim keybinding built in, which would allow me to duplicate lines fairly easily. Being able to quickly toggle between using Vim and regular key bindings would be nice too.

3 Likes

@lizardmenfromspace Should probably add to your meta list!

Not urgent, but I think Sublime Text has had a great line duplication feature (CTRL/Command + Shift + D) and duplicates by line or by selection. I’m sure its not the only editor to have the feature, but I hadn’t explored other editors as deeply.

2 Likes

This is actually the multi-selection that Sublime is renowned for. Yes, it’d be great to have even some of those

1 Like

Most of the other major text editors and IDEs have this feature. I hope it becomes part of the core keybindings, not just in VIM, which not everyone uses.

6 Likes

The Hotkeys++ plugin now has this shortcut.

12 Likes

Chiming in here that I would very much like to see a “duplicate line” hotkey. Coming from a programming background, this is part of my muscle memory and it makes creating Markdown tables so much easier, for example, because I can just copy a table row and don’t have to type the | character manually (or copy the line manually).

3 Likes

+1 for having the ability to set a shortcut for duplicating the current line.

I’d love to have this hotkey. I use this constantly while coding in VSCode and it would make my life way easier for things like lists and structured docs

2 Likes

The Code Editor Shortcuts plugin also has this shortcut, as well as a few more common ones from VS Code and Sublime Text.

4 Likes

If it helps, Obsidian now lets you duplicate a line by having the cursor on it (with nothing selected) and then pressing CTRL + C & CTRL + V.

5 Likes

Note that this feature / the implementation is painful to use and also buggy…

It doesn’t function like other text editors (like Sublime Text, Vscode…)

1 Like

I just performed ctrl-c and then ctrl -v on my Mac, and it just moved the cursor to the bottom of the note. No other changes.

I love VSCode’s cmd+shift+down arrow (on Mac) to duplicate lines. It’s a reflex for me, at this point. I don’t even think about it. I just do it.

1 Like

I’d rly love to see that. as many others have already said, its part of the muscle memory of most programmers.

Yes but the fundamental difference in Obsidian is that Readable line length‑setting is either on or off and Obsidian doesn’t offer any feature to toggle this setting easily on the fly. Line duplication editing action makes most sense in case of Readable line length‑setting is turned off.

Related feature requests about Readable line length—note that some of them might be duplicate feature requests @CawlinTeffid :

https://forum.obsidian.md/t/hotkey-for-toggling-readable-line-lenght/9441
https://forum.obsidian.md/t/enable-readable-line-length-in-markdown-preview-mode-but-not-in-editing-mode/25224

Use settings to edit Hotkeys++ plug-in as follows and assign your own hotkey.