timhor / obsidian-editor-shortcuts Goto Github PK
View Code? Open in Web Editor NEWObsidian plugin to add keyboard shortcuts commonly found in code editors such as Visual Studio Code (vscode) or Sublime Text
License: MIT License
Obsidian plugin to add keyboard shortcuts commonly found in code editors such as Visual Studio Code (vscode) or Sublime Text
License: MIT License
It would be great if this can be supported for this command and two other related commands when selecting text in the name of a note opened in a pane.
Is "delete line" the same as "delete paragraph" built in obsidian?
Side-Note: the new editor has ctrl-shift-k already bind to delete line.
Thank you for the great plugin! Especially, Select word or next occurrence of selection
is very exciting for me :)
I found an unexpected behavior when I used Select word or next occurrence of selection
other than English.
Select word or next occurrence of selection
ああ ああ ああ
It succeeded in selecting the current word but didn't increase cursors.
I read your code and found it to satisfy my requirements by changing it as follows.
https://github.com/timhor/obsidian-editor-shortcuts/blob/master/src/actions.ts#L175
const nextMatch = findNextMatchPosition({
editor,
latestMatchPos,
searchText,
- searchWithinWords: isManualSelection,
+ searchWithinWords: true,
documentContent: editor.getValue(),
});
But I believe it is contrary to your intent. It would be great to solve my problems if you know better solutions :)
Thank you!!
Hi!
I was looking for a way to transform selected text to other formats. My use case was that I wrote a list comma separated and not markdown formatted, and I wanted to transform it via a command.
From:
apple, banana
To:
- apple
- banana
I've seen this plugin supports Transform selection to uppercase
which is similar, only the logic is different.
I was wondering if something like Transform selection to uppercase
with custom js code could be supported or if you know any plugins that have this functionality.
Thank you for the help.
many code editor basically merge those two commands in an "smart expand" command that looks ahead and behind whichever the current scope is. I am a bit used to having both in one command, so it's kind of weird for me to use them as two commands here. And I assume it shouldn't be hard to implement, since the bracket command already considers multiple different types of brackets?
Thanks for your plugin. But I can't update to version 1.13.1, could you please help with this issue?
Selecting a line creates inconsistent behavior.
I set "Go to start of line" to ⌃← and "Go to end of line" to ⌃→ and this works properly.
However, when I try to select the words that I'm trying to move past by holding shift (⇧), the cursor jumps much farther in the text then where the line ends. For example, if I select ⇧⌃←, instead of going to the start of the line, the selection goes back through the doc to the first bullet point it reaches. Using ⇧⌃← on a bullet pointed line seems to have proper behavior.
Obsidian Version 1.1.9 on macOS Ventura 13.0.1 on a M2 Macbook AIr (2022). Code editor shortcuts v1.13.0
With this plugin I can go a little bit of the way towards emacs-like navigation (e.g. with the plugin I can map a shortcut to go to the start of a line and to go to the end of a line). It would be great if I could use it for other emacs shortcuts, for example by allowing the following to be mapped:
In vanilla Obsidian, if the cursor is in a checkbox list and you insert a new line, it will create a new empty checkbox (- [ ]
).
However, this plugin will instead insert a regular list item bullet point (-
)
Note that the inserted checkbox should always be empty, regardless of the status of the checkbox of the line the cursor is on. It should also recognize "alternate checkboxes", which are supported by most themes.
I'm on macOS, Obsidian v0.14.7. Some default hotkeys don't work, like cmd + D
and cmd + enter
. However I can execute these commands from the command palette. Also, if I bind them to other hotkeys, like cmd + Q
and ctrl + shift + Enter
, then they will work.
Also, I use Advanced Cursors before, which also has a feature to select word/ next occurrence. I used to bind this command to cmd + D
as well, and it worked fine.
Opposite of the Delete to End of Line command. I use the sentence Navigator plugin for this but it would be great to remove this and just keep code editor
At first , thanks very much for this plugin, it's a good way, and the only way AFAIK to implement emacs keybindings in obsidian on windows and linux OS.
I notice that there are move cursor right / left commands and go to previous line /next line commands, but emacs need move cursor up and down commands, because go to previous line is not useful on the lines which are wraped, I need move up as i see,not the previous line as the editor deal with.
Hello! First of all, thank you for this great plugin. Using these functions in my vimrc provides an even further vim-like writing experience.
I'm currently trying to extend this plugin's functionality by creating two functions: deletePrevChar
and deleteNextChar
.
deletePrevChar
would simply delete the character to the left of the cursor (equivalent to the keyboard key Backspace
). <ctrl-h>
is mapped as backspace
in Insert mode in vim. I tried remapping in .obsidian.vimrc
but it doesn't work due to CodeMirror limitation, hence I'm trying to achieve the same result with this seemingly unnecessary function. By creating these functions I could do the following in my .obsidian.vimrc
:
exmap deletePrevChar obcommand obsidian-editor-shortcuts:deletePrevChar
imap <C-h> :deletePrevChar
(deleteNextChar
is just for the symmetry (I won't personally use it)).
The problem is that I can't develop this plugin.
Steps to reproduce:
cd /home/user/Obsidian/Obsidian-vault/.obsidian/plugins
obsidian-editor-shortcuts
git clone https://github.com/timhor/obsidian-editor-shortcuts.git
cd obsidian-editor-shortcuts
nvm use
yarn install
yarn start
Command failed to execute: obsidian-editor-shortcuts:goToPrevChar
app.js:1 TypeError: cm.operation is not a function
at withMultipleSelections (eval at <anonymous> (app.js:1), <anonymous>:108:8)
at Object.editorCallback (eval at <anonymous> (app.js:1), <anonymous>:587:35)
at Object.e.mobileOnly.xb.isMobile.e.checkCallback (app.js:1)
at Mz (app.js:1)
at e.executeCommandById (app.js:1)
at e.onTrigger (app.js:1)
at e.handleKey (app.js:1)
at t.e.handleKey (app.js:1)
at t.handleKey (app.js:1)
at e.onKeyEvent (app.js:1)
Any idea as to why Obsidian wouldn't recognize the development version? The file size of main.js
emitted from yarn run
is also different from the released version.
Any help is much appreciated. Thank you!
It would be great if certain commands can work in preview mode/reading view, e.g. Go to previous/next heading
.
Would it be possible to extend the case conversion routine to change the word to title case, as well as toggling between upper and lower case? It looks as if it should be simple enough.
Hi there, thank you for the amazaing plugin. I'm wondering if you could add the function that when one holds down the mouse and drag and hold option at the same time, the cursor will choose the scope that the mouse chooses, just like what we can do in sublime.
Executing the duplicate line command in a sidebar document now does them in the main edited document instead.
Hi, thanks for this useful plugins! I like the idea, it's simple but still useful. I use Sublime and I'd love to see the following commands added to Obsidian via this plugin as well.
find_under_expand
)paste_and_indent
)expand_selection
to brackets
)copy_with_empty_selection
, found in the preference section, not the keybindings section)In addition to the existing "Transform selection to x case", it'd be nice to support a "Toggle Case" which can rotate through the three states (upper, lower, title). This functionality is covered in another plugin, https://github.com/MatthewAlner/obsidian-toggle-case, but feels like a better fit to add the feature here than install an additional plugin.
Thank you for the plugin!
Great plugin BTW!
Oddly, Obsidian doesn't implement Previous word/next word and it seems like this plugin would be an ideal candidate to implement that.
You've already got all the basic nav actions supported, just missing the next prev word....
Shortcut that moves current line up and down (Alt
+ ↑
/ ↓
is the VS Code analog).
Ideally, this should also properly skip indented lists (as is behavior in VS Code), for example:
* A
* B
* C
* D
moving B down one line should move it before D:
* A
* C
* B
* D
In VS Code and IntelliJ, after deleting a line, caret will be put on the following line. But with this plugin, caret will move one line up.
Could this behavior be fixed to mimic other text editors?
Would it be possible to add a save all hotkey for edited files? Or something of the sort? I can't keep up with what I have edited and what I haven't currently.
I find this feature (from Visual Studio) pretty helpful to reorder e.g. lists.
e.g.;
line one
line two
line three
line four
So if i select line two and line three and press Alt + Cursor Down i get:
line one
line four
line two
line three
Hello @timhor !!!!
A brief introduction before talking about the FR :)
1️⃣ In version 1.0.7
we had the command Select Word that selected the word based on the caret cursor position.
2️⃣ In version 1.0.8
this command gains superpower which lets us select word and select the next occurrence as well :)
My FR is about bring back the Select Word
in a separated command
I know that look strange to have two commands like this. Let me show how Select Word
can have multiple workflows when you combine with other plugins :)
ℹ️ I import a lot of content to Obsdian. Especially Book Highlights, Podcasts Transcriptions and Web Artciles
ℹ️ All my writing is created inside Obsidian. Even when I have to send a message, I write first in Obsdiamn than send to external sources.
ℹ️ Additionally, I use a lot of html tags to decorate my notes.
This way I use a lot of Line Selection, Paragraphs Selection and Word Selection to easily apply this decorations to my notes.
This Macro automatically Select the word at the caret cursor and then apply the decoration.
The beautiful thing here is that the command respects if something where already select
📽 2 Selected Words Selected
The video below shows why I need a command to only Select one Word
📽 3x Michael Jordan
In words: when I have two words select and I have the same words before and/or after the command Select Word and the Next Occurrence
will apply the decoration to the next other matches
But when we have a workflow where we want to apply some type of rule (in my case html tags) only to the select text and avoid the next occcurance I can use the same command.
-The best scenario for this would be the old command that only selects one Michael Jordan
:)
We can apply this same insight to many workflow in Obsidian, I decided to share this one because its easy to see :)
Thanks for reading this !!!!! I hope you like my suggestion 🙏 🙏 🙏
Sorry for the long text. My idea was to show to you that a isolated command is something really important :)
Let me know if you need more information !!!
Have a great day 🌞
Something missing from Obsidian at present is the ability to perform operations on sentences, rather than lines.
You can do this in Vim mode, but that has other drawbacks. I can see, sort of, how sentences might be defined in pseudocode
"[\?\!\.] "
;but I don't know how to put that into typescript or indeed any language other than Python.
Once a sentence is defined as a unit of movement, you can put in the commands that prose writers need:
All of these operations are really useful if you're writing continuous prose. I can have a try myself, but I can't guarantee success.
I commonly use expanding selection in both Emacs and Intellij, for example, something like this (with the cursor and selection denoted by |
):
testRegisteredDomainProcessor(buildEvent("goog|leapis.com"), "googleapis.com", null, "googleapis.com", null);
*expand*
testRegisteredDomainProcessor(buildEvent("|googleapis|.com"), "googleapis.com", null, "googleapis.com", null);
*expand*
testRegisteredDomainProcessor(buildEvent("|googleapis.com|"), "googleapis.com", null, "googleapis.com", null);
*expand*
testRegisteredDomainProcessor(buildEvent(|"googleapis.com"|), "googleapis.com", null, "googleapis.com", null);
*expand*
testRegisteredDomainProcessor(|buildEvent("googleapis.com")|, "googleapis.com", null, "googleapis.com", null);
*expand*
|testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", null, "googleapis.com", null);|
It would be great if this worked for text also, for example, just expanding to the current word would be super helpful. Something like:
Hello. This "is so|me text. Yep."
Hello. This "is |some| text. Yep."
Hello. This "|is some text.| Yep."
Hello. This "|is some text. Yep.|"
Hello. This |"is some text. Yep."|
Hello. |This "is some text. Yep."|
|Hello. This "is some text. Yep."|
I picked the unit that made the most sense to me (word -> sentence -> quotes -> outside quotes -> enclosing sentence -> entire text), but even just having "expand to word" would be very useful.
Thanks for this plugin!
Hello,I think it‘s may useful to add a shortcut that toggle line numbers inside editor like the plugin
It would be great if this can be supported.
E.g. alt/option - command + up or down arrow to vertically insert cursors across multiple lines. Apologies if I overlooked something and this is already possible!
Is it possible to add this functionality like what is found in Sublime Text?
If the cursor is on a boundary of frontmatter and I insert a line, I get a line with a -
. But this isn't a list item--it's just a fence.
--- %%cursor could be here%%
tags:
updated: '2023-01-09 11:06-08:00'
created: '2023-01-09 11:06-08:00'
--- %%or cursor could be here%%
- %%inserting a line incorrectly adds a `-`%%
For example:
(hello)
(hello)
(hello)
Selecting the first (hello)
and hitting cmd + D
doesn't select the next one. But just selecting hello
works.
Do you think it's maybe that searchText needs to be escaped here?
obsidian-editor-shortcuts/src/utils.ts
Line 266 in 1e0e6e6
Hi @timhor! Thanks so much for creating this plugin, I find myself using it all the time!
Wondering if you would be open to adding a few commands to complement the existing set:
Thanks again for sharing this plugin!
Hello, thanks for developing this plugin first of all!
Version: v1.10.0
I tend to use the "Select word or next occurrence" feature often and found that there's a bug when attempting to select Markdown formatting artifacts in Live Preview & Source mode.
To reproduce:
### Test 1
### Test 2
### Test 3
Selecting just the ###
and invoking "Select word or next occurrence" should select the next instance of ###
into the selection, but it does nothing. I was also able to repro using lists as well, searching for -
.
The bug might be in findNextMatchPosition
@ https://github.com/timhor/obsidian-editor-shortcuts/blob/master/src/actions.ts#L210
As a Sublime Text user, here are some other key binding suggestions:
Code Editor Shortcut: Expand selection to brackets
Ctrl + Shift + M
Code Editor Shortcut: Insert cursor above
Ctrl + Alt + (up arrow)
Code Editor Shortcut: Insert cursor below
Ctrl + Alt + (down arrow)
Command palette: Open command palette
Ctrl + Shift + P
Quick switcher: Open quick switcher
Ctrl + P
This one isn't related to Sublime Text but just something I added personally:
Code Editor Shortcut: Expand selection to quotes
Ctrl + '
This would be a fantastic feature to have! :) I usually have it bound to Alt+ArrowUp/ArrowDown in other editors.
Installing this plugin for the several dozenth time on a new vault , had trouble remembering the name though.
From within Obsidian, when Browsing Community Plugins, I tried searching for:
vscode
vscode
I never even thought to search just code
or Visual Studio Code
.alt up
(and variants/variations?)edit
vscode
somewhere in the description that shows up in the screenshot.I'm trying to install the plugin in the standard way (browse community plugins). When I click install, it gives me an error message: "Failed to install plugin"
The console spits out a not-very-informative error as well
app.js:1 Error: Request failed, status 404
at new t (app.js:1:717762)
at Jw (app.js:1:717954)
at app.js:1:718631
at app.js:1:235836
at Object.next (app.js:1:235941)
at a (app.js:1:234680)
I'm running Obsidian Version 1.1.16 on macOS Monterey 12.3.1.
I appreciate that you specify "Ctrl + Enter for 'Insert line below' may conflict with the default shortcut for Toggle checklist status; changing/removing one of the bindings is recommended."
In Obsidian, I'd love to be able to use Ctrl + Enter for "Insert line below" when I'm in a code block, but keep it for "Toggle checklist status" when I'm anywhere else.
Not sure if/how that is possible, though.
Hello again @timhor !!!!!!
My FR is to add support for non-ASCII characters to the command Select Word
:)
When you select a word in a language like Portuguese or Finnish, we have this as result:
As you can see form the images, it’s only selecting the characters until the non-ASCII characters.
This is a list of non-ASCII characters for the Portuguese and Finnish language:
áàâãéèêíïóôõöúçÁÀÂÃÉÈÍÏÓÔÕÖÚÇ
Since I was born in 🇧🇷, Portuguese is my mother language. These type of characters are the used in every portuguese word as you can see above:
English | Portuguese |
---|---|
Coffee | Café |
Sugar | Açúcar |
John | João |
The same behavior applied to 🇫🇮 and many countries :)
I hope you could add support for these characters 🙏 🙏 🙏 .
Thank you very much for reading this !!!
Have a great day 🌞
First of all, thx for this great plugin. Although i don't use obsidian for any coding purposes whatsoever, i really love a few shortcuts for navigating through open files (e.g. jump to next heading, or jump to next line, select line)
It would be really great if a few Shortcuts for navigating lists would exist too.
For example:
Thx again for the great work :)
I set my keybindings for 'Go to next/previous heading' to >
and <
, respectively, and also have vim mode enabled. I was hoping to hold down >
to quickly scroll through my notes by heading, but after skipping to one heading when folded, it instead starts rapidly indenting the newly-jumped-to heading (which is a result of vim's >>
keybinding). This appears to mean that this plugin doesn't handle repeat keys on at least these two commands (and maybe others).
Separately, is there a way to only jump to the next heading of the same level (e.g., if you're within the text of a h2 heading, and there is a h3 heading also within that h2 block but your cursor is not in the h3 block, jump past the h3 block to the next h2 heading)?
For VSCode, you can select multiple lines and join them into one line with a shortcut. Is it possible for this plugin?
So I've put something together in Keyboard Maestro that allows me to add new lines above/below, which actually adds new numbered entry (as it simulates the [return] keystroke) when in a numbered list. Would you consider setting up the new line shortcuts so that they would do the same (or at least providing an option for that)? Currently they add a blank line, which is not that handy when what you're trying to achieve is to get a new list entry midway through.
say I want to merge two lines:
- one point
- second point
here, the result would be:
- one point- second point
A much more elegant result, however, would be to remove the preceding -
:
- one point second point
Just an idea. Probably complex to handle nested quote characters right unless there is a js library already available.
Hello @timhor !!!!!!
Before talking about my FR, I wanna say thank you for creating this amazing plugin. I use it a lot and everyday :)
My FR is simple to explain: would be amazing if we have a new command to select a markdown table.
It’s the same meaning of Select Word
Applied to markdown tables: if the caret cursor is inside a table,it will select the whole table when the new command is pressed
Let me explain: there is a new plugin in beta called Markdown Table Editor that lets you edit markdown tables inside Obsidian !
That’s why I’m asking for this feature :)
Thanks for reading this!
Have a great day!!!!!!
For example, if a note has 200 lines. Entering any number >200 will jump to line 200
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.