Replies: 5 comments 8 replies
-
Beta Was this translation helpful? Give feedback.
-
Oh, true, line is better!
I haven't actualle checked how easy it will be in Obsidian API to access these different elements such as line and paragraph, but at least now my idea is that paragraphs would mean text blocks separated by empty space between them, so a single linebreak would not be enough to separate paragraphs. Technically a paragraph would refer to HTML's Maybe there would need to be another option between line and paragraph: something that selects from previous linebreak chracter to next linebreak character.
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Now that I have been thinking about this for a while, I'm not so certain if this would be the best way to implement this. The ability to select text before executing a command is a good idea per se, and I would like to find some form to implement it. But I'm not confident about implementing this in the form of a variable. So far, Maybe a better idea would be to implement some kind of preactions: select something if nothing is selected, activate last active file if no file is active, activate a certain file if no file is active, always activate a certain file etc. These would be completely separated from variables. And I should start a new conversation for this, and then edit this current conversation's title so that it talks about a new Preaction for selecting text, rather than about editing |
Beta Was this translation helpful? Give feedback.
-
Yep, this is all correct. Thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is just a very quick idea that I haven't thought through yet. If there is a caret in the text (in editor mode), but nothing is selected, a command could define what to do:
{{selection:select-word}}
: Highlight the current word at the caret (only if nothing is selected).{{selection:select-row}}
{{selection:select-line}}
: Highlight the current line at the caret, adhering to soft wraps. (only if nothing is selected).{{selection:select-I-DONT-KNOW-YET}}
: Highlight the current line at the caret, adhering to hard linebreaks. (only if nothing is selected).{{selection:select-paragraph}}
: Highlight the current paragraph at the caret (only if nothing is selected).{{selection:select-all}}
: Highlight the whole content in the note (only if nothing is selected).{{selection:select-all-but-yaml}}
{{selection:select-yaml}}
{{selection:select-link}}
: Highlight the current link at the caret (only if nothing is selected). (Thanks, @FelipeRearden!)This could be good for some e.g. Use this as input and replace it with output tasks, and you don't have to always highlight text beforehand, just point the caret at a correct word. Would there be any use for something like this?
Another feature, added 2022-03-02:
Ability to cancel execution if nothing is selected
This is completely different than the "select" preaction described above. It could work with some events (prevent automatic execution if no text is selected), and also prevent accidental hotkey/command palette originated execution in case a user accidentally tries to execute a shell command without having anything selected, and if the shell command is not designed to work properly with an empty selection.
There would be an option to either cancel silently or with an error message.
Another solution to this might be to change the
{{selection}}
variable to raise an error if nothing is selected. Then with the possibility to define default values for variables (will be implemented together with custom variables #146 ), the variable can be defined to allow execution even without a selection, if needed.Edit 2022-12-10: This has now a separate discussion: #299
Beta Was this translation helpful? Give feedback.
All reactions