Vim-mode Powerful Shortcuts

For those familar with vim, you’ll probably agree straight away! Make sure to upvote this request!

For those who havn’t heard of it, let me tell you why I feels it’s essential to have this form part of Logseq.


What is Vim?

Vim is a powerful text editor where every key is a shortcut, what I’m refering to with this request, is adding vim shortcuts to navigate and edit text in Logseq!

Video Demo

Here’s a 10 second video to show you what I mean.

This video was made using org-mode in Spacemacs (Emacs with Vim-mode)

Powerful shortcuts

Vim mode is a way to use every key as a powerful shortcut.

The question that this raises for beginners is:

"How do I type normally if every key is a shortcut?’

The idea is that there are 2 modes “typing mode” and a “vim mode”, you can go into vim mode by pressing ESC and you can start writing with instert mode by pressing i.


Of course it feels unnatural at fist, but when you are in vim-mode (after pressing ESC) the world is yours!

You can edit text really fast, like shown in the Video demo above.

Learning Vim

I make learning resources for productivity. Teaching Vim is one of my main goals, doing it through Logseq would be amazing.

If you want to learn mode I have YouTube Video on Vim-mode In Obsidian.


Suggestions for the awesome Logseq developers

My programming levels are not there yet, but I highly recommend taking a look at Obsidian’s Vim-mode (which can be activated in Settings > Editor > Vim keybindings.)

According to my understanding it uses a pachake to integrate vim-mode through code-mirror, which seems to be the best way to add it to LogSeq.

Other apps that integrate Vim

  • Zettlr
  • evil mode (for emacs) / Spacemacs

Being able to navigate Logseq with Vim-mode would be amazing!

Great demo, i would love to see a vim-mode inside of logseq too!

3 Likes

My two cents: it might be possible to implement 80% with relatively low effort by relying on existing extensions like surfingkeys and ensuring Logseq works well in conjunction with it. Although won’t work for Electron app :frowning:

4 Likes

Hey @karlicoss thanks a lot for the recommendation. I’ve looked at similar projects for browsers, but that one I must admit look really interesting.

However, after the Desktop app was released I don’t see myself going back to the browser! Since the whole experience is so much better.

With that said I appreciate your suggestion it does look really interesting and I might use it for other things since currently I only use vimium

Thanks!

Appreciate it! yeah it would truly be amazing!

Yeah, and probably unlikely it would be as smooth as a native vim keys support. Just mean that it might be a low hanging fruit (and ultimately will help towards better native keys anyway) :slight_smile:

Yeah exactly, for developers interested to see how this could be added, I think Obsidian does it perfectly.

In Obsidian it’s not a 100% capable vim, but 95% of vim navigation works and there is even a simple .vimrc

(Obsidian’s vimrc it doesn’t support additional vim plugins, but works for remmaping certain keys if needed)

Initially a .vimrc might not even be needed.


Optional Toggle

Above all, it would be important to make vim shortcuts an optional toggle feature. (again that’s how Obsidian deal with it, which I think works great)


This way we don’t force new users to learn vim if they don’t want to, but it’s a learnable skill that can make Logseq’s experience a lot more pleasant as users progress into power users, and of course for those of us who use vim for writing and editing text.

Key mapping support in .vimrc alone is already very powerful and a lot can be done with it.
e.g. I could remap something like bi[[<ESC>ea]] to a shortcut like ,,l to quickly linkify any word under a cursor

2 Likes

That’s actually an awesome idea!


I agree a .vimrc can be really powerful specially for macros.

For instance something like this is always needed for a good writing experience:

nmap j gj
nmap k gk

so that going down every line of written text, works as expected.


I also really enjoy saving macros in my .vimrc , but yeah even a first integration of vim shortcuts without a .vimrc would be an awesome thing, and if later a .vimrc could be added that’d be even better!

2 Likes

There’s a Roam Research plugin called Roam Toolkit that lets you use Vim keybindings to navigate through blocks. Here’s a the demo from their GitHub README:


I would imagine that Vim keybindings could work similarly in Logseq.

5 Likes

No way, that’s amazing! Is there any way to use it in Logseq? or is it more for inspiration?
hahaha you nearly tented me to move to Roam
Once logseq has vim, there’s no way I’ll ever leave Logseq hahah

2 Likes

It would be nice if it worked with Logseq, but I think it only works on domains starting with roamresearch.com. I just posted it for inspiration. :smiley: The closest thing to Roam Toolkit is probably Vimium, which allows you to navigate websites and click on anything within a site with Vim keybindings, but you can’t edit text like real Vim.

2 Likes

I like modal interfaces like Vim - but in the case of LogSeq, I think they should continue developing their keymap and of course reuse Vim keybindings when applicable. Like Gmail lets say. Just take cues from Vim-land instead of having a Vim-mode.

OTOH I wish I could navigate in LogSeq without entering edit mode all the time.

2 Likes

I agree with more keymaps vim mode will become possible. In general it’d be great to be able to make vim optional. So that those who don’t want to use vim are not confused by it.

I did a quick search and I don’t know what you meant by vim-land vs vim-mode

Got you, nice! I agree vimium is great for general navigation, but you said, it’s not really for text editing like real vim is

Sorry -by Vimland I just meant the kind of applications that take cues from Vim’s modal qualities without using the exact keymaps.

Another good example is GitHub - mgsloan/todoist-shortcuts: Comprehensive keyboard shortcuts for Todoist, via browser extension - a todoist (web version only) extension which makes it much less mouse dependent.

1 Like

got you! that makes sense!

1 Like

Replying to this old Vim-mode thread to highlight the custom keyboard shortcut features available now in Logseq beta 0.1.x. See https://logseq.github.io/#/page/custom%20keyboard%20shortcuts and scroll down to “Example of a vim-like shortcut setup”.

4 Likes

Perfect, yes I’ve been using those shortcuts and they some excellent progress on Vim-mode in Logseq!

It’s still be amazing to use some other features

Examples

  • y for yank (copy)
  • p for paste.
    Visual line with shift + v for example.

But what is currently possible is some great progress so far, The Logseq team is on fire, thanks guys for the great work

4 Likes

Checking out how VIM works in Obsidian.
Did I understand correctly that at the moment, we need to update the keybindings to match that to VIM?

So bind J to (down)? But since we can’t use J (conflicts), we use ctrl-j right?

Or just copy paste the closure (?) script to the settings?

Did I understand correctly?