Hotkey for select curent line

please make a hotkey that select current line at cursor

6 Likes

This could be done with vim mode if you’re already using that by using Shift + V

2 Likes

i dont use vim

1 Like

Current workarounds / solution …

… which might temporarily cover a lot of use cases for the proposed hotkey:

Line (paragraph) under cursor can be selected by triple click.

Current line (around caret):

  • Wrapped part of line surrounding caret(sometimes called cursor) can be selected by sequence of hotkeys: [End, Shift+Home]
  • When that part starts with indentation, then press Shift+Home once more to include the indentation in the selection.
  • Whole wrapped line can be copied by Ctrl+C or cut out (= deleted) by Ctrl+X when no text is selected (Otherwise you would get the selection instead of current line). If some text is selected before this action, then first cancel the selection e.g. by pressing Escape or Left or Right or click. Canceling multiple selection might require sequence of presses.
  • Whole line can be selected by cutting it out by Ctrl+X and then immediately pressing Ctrl+Z (Undo). (tested in Obsidian v0.10.1 in Windows 7)

Sequences of presses can be triggered by single hotkey using e.g. AutoHotkey or Keyboard Maestro. This (or some clipboard manager) can also deal with loss of previous clipboard content produced by Ctrl+X.

2 Likes

Proposed extension of behavior for wrapped lines:

  • In wrapped part of line (not first part):
    Second press of Shift+Home (/ of Home while holding Shift) extends selection to the beginning of current line,
    including leading indentation (to unify number of keypresses for the same effect, regardless of wrapping).
  • Equivalently for Shift+End (here the indentation is not an issue).
  • Side-effect: This would also allow to navigate to start of paragraph by pressing sequence [Shift+Home+Home, Home]. Equivalently for end of paragraph.

Edit: Reposted as separate feature request:

1 Like

This is awesome and really should be documented in the Help file. I’ve been missing functionality like this and wishing Obsidian had it. All along it did!

I don’t understand why this is part of workaround #3. It seems like it should be part of your last workaround (#4), right? Otherwise, I don’t understand what you’re saying here…there is no “selection” if you use Ctrl-C or Ctrl-X to copy or cut a paragraph that is not selected.

Anyways, so glad you posted this.

1 Like

@FedeK

The QuickAdd plug-in have a feature that let the user create a hotkey that selects the active/current line . Might be what you are looking for :slight_smile:

@looper Thanks for feedback. Let me know if current edit of paragraph need 3 eliminates the confusion.

1 Like

hey. i just downloaded the plug-in. still confused how i can add a hotkey to select active line, i can’t see it in the command palette. thanks!

You have to enable making the thunder yellow
image

My proposal would be to override Control+A:

  • Press Control+A once → current line is selected
  • Press Control+A again → entire document is selected

I believe this is how OneNote functions and I find it very useful.

6 Likes

Confirmed that this works.
For more specific instructions:
After installing the plugin, go to the settings.
Then Manage Macros, create a new Macro, name it something like “selectActiveLine”, and add the Editor command “Select Active Line”.

The Macro should just have one command now. Close it.

Create a Template, name it “Select Active Line”, add the “selectActiveLine” macro. Make sure that the lightning bolt in the template is highlighted yellow

Back in Obsidian Hotkey Preferences, search for “Select Active Line”. You can now set that to whatever hotkey you’d like

I’m not sure where I got this from, maybe Xcode, but I prefer ctrl+L as the hotkey to select line

1 Like

More convenient plugin which adds many useful line manipulation actions including “Select line”: obsidian-editor-shortcuts

Also select-current-line-plugin exists but I didn’t try this one