logseq-plugin-vim-shortcuts
logseq-plugin-vim-shortcuts copied to clipboard
Add part of VIM key bindings experience to Logseq
:coffee: Get me a coffee if you like this plugin!
logseq-plugin-vim-shortcuts
This plugin provide some shortcuts which give Logseq a VIM-like feeling.

Supported shortcuts
j: Move to next line. In visual block mode, it is for selecting down.k: Move to previous line. In visual block mode, it is for selecting up.h: Outdent.l: Indent.J: Move to next sibling. In visual block mode, it is for moving down.K: Move to previous sibling. In visual block mode, it is for moving up.H: Highlight focus out to parent level.L: Highlight focus into child level.aandA: Move the cursor to the end and enter edit mode.iandI: Move the cursor to the beginning and enter edit mode.yy: Copy current block content. Only supports one block – for copying multiple blocks, please usecmd+c.Y: Copy current block ref.p: Paste clipboard content to next sibling. Only supports one block – for pasting multiple blocks, please usecmd+v.P: Paste clipboard content to previous sibling. Only supports one block – for pasting multiple blocks, please usecmd+v.o: Insert an empty block to next sibling.O: Insert an empty block to previous sibling.dd: Delete current block. Child blocks will also be deleted, but only current block content in the clipboard.T: Scroll to top, because Logseq usesggto go to graph view.G: Scroll to bottom.u: Undo.ctrl+r: Redo.gu: Change block content to lower case.gU: Change block content to upper case.mod+shift+u: Toggle block content between lower and upper case.NUMBER+mod+shift+u: Trigger different case style, supports 1–16.zo: Extend block.zc: Collapse block.zO: Extend block hierarchically.zC: Collapse block hierarchically.NUMBER+m: Save current page or block as a mark toNUMBERregister.NUMBER+': Load saved mark on main region.NUMBER+mod+': Load saved mark on right sidebar.cmd+j cmd+j: Exit editing mode.ctrl+[does the same thing.mod+alt+j: Join next sibling block.mod+shift+enter: Jumping into internal page or tag.mod+shift+;andmod+alt+;: Trigger command mode. This provides many handy commands to use, explained below.ctrl+a: Increase the first found number in block. Supports multiple selections and combo.ctrl+x: Decrease the first found number in block. Supports multiple selections and combo.x: Cut a leading character. Supports multiple selections.x: Cut a leading word. Supports multiple selections./: Trigger search in page bar on the below. Supports smartcase.n: Search next search match.N: Search previous search match.sb: Search block content in Baidu.se: Search block content in Wikipedia.sg: Search block content in Google.sh: Search block content in Github.ss: Search block content in Stackoverflow.sy: Search block content in Youtube.ctrl+v: Toggle visual block mode.mod+/: Trigger emoji picker UI.
Modes
Normal mode
A block is focused/highlighted.
Insert mode
You can edit a block.
Visual block mode
You can select more blocks up and down and move the selected blocks using j and k.
Command mode
In VIM this mode can be triggered by :, but here, the shortcut is mod+shift+;, also can be memorized as mod+:. After trigger, you can find an input area at the bottom, you can input some commands here like in VIM. For now it's about 10+ commands, but I believe that would be more.
NOTE: on Windows, the trigger is ctrl+alt+;
The bottom input features
- Autosuggestion when you input.
- Press
Tabif only one command matched, the matched command will be autocompleted right away. - Press
UpandDownto traverse command history, it's a 1000 limit history, I think it's enough to use. - Press
Escto close command mode and back to the main window. For now Logseq can not get focused automatically sometime. so you need to click the main window to continue. - Just in case bug stuck, there are
Runbutton andCloseat bottom right to help you trigger behaviors.
Supported commands
:NUMBERto scroll to specific line or:-NUMBERto scroll to specific line to the end or:.NUMBERrepresents scrolling to NUMBER * 100% of the page.:s/and:substitute/: Replace current block according regex, e.g.s/foo/bar/gi, Notice it support Regex modifiers.:%s/a nd:%substitute/: Replace current page blocks according regex, e.g.%s/foo/bar/gi.:marks: Show marks.:delmand:delmarks: Delete specific mark ids, e.g.:delm 1 2 3.:delm!and:delmarks!: Delete all marks.:mand:mark: Go to specific mark, e.g.:m 1.:go: Go to existed page or block, e.g.:go 2022-02-22or:go ((6219c981-256a-4464-bc62-4ecfab4c2141)).- There are some shortcuts for page name:
:go @and:go @index: Go to Contents page:go @todayGo to today's journal page.:go @yesterdayGo to yesterday's journal page.:go @tomorrowGo to tomorrow's journal page.:go @prevGo to prev-day's journal page, if currect page is not a journal page, fallback to @yesterday.:go @nextGo to next-day's journal page, if currect page is not a journal page, fallback to @tomorrow.:go @backGo to backward page.:go @forwardGo to forward page.
:go!: Go to existed page or block, create one if page not exist, e.g.:go 2022-02-22or:go ((6219c981-256a-4464-bc62-4ecfab4c2141)).:go!and:gosupport--nsand--namespaceto go or create namespace page. e.g. you run command:go! subpage --nsontestpage, then you will be redirect totest/subpagefor saving your time to input prefix chars.
- There are some shortcuts for page name:
:reand:rename: Rename current page name, if target page exists, page content will be merged.:undoand:redo: Undo and redo last edit.:loremand:lorem-ipsum: generate random blocks in same level, with--unit word|paragraph|sentenceto change random block unit.--unithas a short style as-uword,paragraphandsentencealso have short styles asw,p, ands.- also support
-p,-s,-wand--paragraph,--sentence,--word.
:emoji: Insert emojis by searching keyword, you can repeat emoji by appending a number.:emoji-picker: Insert emoji by emoji UI.:sortandrsort: Sort page first level blocks with no focus any blocks and sort sub level blocks with focus on one block.:bg [namedColor|hexColor]: Set block background color, support multiple block selection.:bg-picker: Trigger a color picker to select block background color, support multiple block selection.:bg-random: Set block background color randomly, support multiple block selection.:bg-clear: Clear block background color, support multiple block selection.:copy-path: Get page or journal absolute path, so you can edit it outside of Logseq.:open-in-vscode: Open page or journal in VSCode.:wand:write: Save current page, actually this is a fake one, because Logseq save automatically.:wq: Save current page and quit vim command mode.:qand:quit: Quit vim command mode.handhelp: Show a help message modal.
Case Change Styles
1: Toggle upper and lower case, the default behavior.2: Change to upper case. e.g.LOGSEQ IS SO AWESOME3: Change to lower case. e.g.logseq is so awesome4: Change to title case. e.g.Logseq Is so Awesome5: Change to sentence case. e.g.Logseq is so awesome6: Change to path case. e.g.logseq/is/so/awesome7: Change to capital case. e.g.Logseq Is So Awesome8: Change to constant case. e.g.LOGSEQ_IS_SO_AWESOME9: Change to dot case. e.g.logseq.is.so.awesome10: Change to header case. e.g.Logseq-Is-So-Awesome11: Change to param case. e.g.logseq-is-so-awesome12: Change to pascal case. e.g.LogseqIsSoAwesome13: Change to camel case. e.g.logseqIsSoAwesome14: Change to snake case. e.g.logseq_is_so_awesome15: Change to swap case. e.g.lOGSEQ IS SO AWESOME16: Change to random case. e.g.logsEQ IS SO awESoME
Mark feature notes
- Logseq have
FavoritesandRecentfeature, and we also have aTabsplugins, the mark feature kind of like Tabs position, but give the power to yourself to decide which is which, that feels good to me. - Marked pages and blocks can be persisted automatically and graph separately.
- NUMBER can be more than 10, actually thousands if you wish.
- The
mshortcut could be conflicted withMarkmapplugin, so if you met this issue, please upgradeMarkmapplugin to latest version. - NUMBER=1 is the default one, so you can just press
mto save and press'to load for mark 1.
Slash commands this plugin added
Because some VIM shortcuts or commands may also need to be as a slash command, so this plugin provides some.
/Insert Emoji: Insert emoji at current position./Sort Blocks: Sort sub level children blocks from a to z./Reverse Sort Blocks: Sort sub level children blocks from z to a./Random Bg Color: Set block background color/Children Random Bg Color: Set children blocks background color
Named Background Colors
The named colors you can use in :bg command are from here
Search in page
Like in VIM, if you press / you can trigger in-page search, and it support smartcase which means if you search in lower case it will match case insensitive and if you search a keyword including upper case char then it will match case sensitive.
Other notes
- Logseq keybindings support may be changed in future, so just use it for a while if you need it, and it may be conflicted with Logseq future shortcuts.
- Not exactly same with VIM key-bindings, just mimic.
- If you are on journal home page, some shortcuts will redirect you to specific page, because there is no API can stay journal home page and move block highlight line.
- Some shortcuts are not perfect for now, maybe need more polish and some support from Logseq Team.
- There may be more shortcuts coming soon.
- Stay tuned.
- Copy here not means copy to system clipboard, just in memory of Logseq.
- The
VIMscroll to top shortcut isgg, if you want it, you can change Logseq gg shortcut to another one, and set gg in plugin settings JSON file. - Some shortcuts support VIM-like combo actions, that means pressing
N+actionto run actionNtimes. - The join shortcuts can only join siblings without children blocks and should not be trigger too fast in editing mode.
- Jumping internal page support combo action to select which page to jump.
- All actions support multiple key bindings in settings JSON file.
modmeansCmdon Mac,Ctrlon Windows/Linux.- Recommend version of Logseq is
v0.5.9+.
❤️ Buy me a coffee
If this plugin solve your situation a little bit and you will, you can choose to buy me a coffee via this and this, that means a lot to me.
Licence
MIT