VIM: always default to NORMAL when opening a note

MOD EDIT: this topic is about always defaulting to NORMAL mode (instead of maitaining the current mode) when opening a note (even in the same pane)


This is a consistent stumble for me as I move between notes often to quickly capture text–the complication is I never want to type where the cursor lands on an opened note. For those who use VIM, NORMAL mode is the expectation. :slight_smile:

Edit: Now I’m finding that Obsidian does start in NORMAL-- so I’m now trying to figure out when it falls into INSERT when I’m not expecting.

Could you be hitting some unintentional key without noticing? Like you wrote in the edit, it does start in NORMAL, and I’m using it all the time and haven’t noticed what you’re describing.
I really hope my request Support loading Vim commands from configuration (vimrc-style) will be picked up at some point (more comments and likes will help :pray:) and we’ll then be able to do permanent mapping to work-around issues like this one…

Trying to find it. Found a different issue, when you use the tag browser to open an item, it opens the editor with a range around the tag, but no active text cursor. You have to use the mouse to force one to start in the newly opened document.

I’m still looking for that rough edge I was hitting yesterday…

Mine normally defaults to normal mode. The only time I see it default to insert is when I toggle preview mode “while still in insert mode” then toggle back to edit mode, which keeps the insert mode state. I do have the “Default view mode” set to Preview.

It would be nice to always start in normal mode for “edit”

Now I’m kinda seeing it random set to insert mode. I can’t really tell if it was because I was editing the particular note before or not.

Request: Edit mode for vim, Always start in normal mode or make it a boolean toggle?

Steps to reproduce

  • Enable vi mode in Obsidian preferences
  • Open file
  • enter edit mode
  • enable vi insert mode
  • click on a different file in the file navigation pane, open a new file through a search result, etc.

Expected result

The newly opened file will open in vi Command mode (NOT edit mode).

Actual result

The new file is opened in edit mode.

Environment

  • Operating system: MacOS 11.1
  • Obsidian version: v0.11.0

Additional information

vi is a modal editor with two modes: command mode and edit mode. In normal vi/vim editors, one must exit edit mode in order to open a new file. When the new file is opened, it is therefore opened in command mode.

Obsidian’s current behavior is unexpected and confusing; when a new file is opened, you may want to go to the end of the file (“G”), search for a string in the file ("/search string"), or perform other commands. Due to the fact that Obsidian’s vi mode persists (per pane) between files, it makes it very easy to start typing commands but instead deface the newly opened file.

I would suggest that regardless of other obsidian settings (like “default view mode”), when a new/different file is opened in a new or existing pane, and vi mode is enabled, the file is opened in command mode, not edit mode.

The “bug” is also related to the issue linked below in the following manner: When clicking on a link in a search, the file is opened to the search matching location. However, since one never knows what mode vi happens to be in, using command-mode keys to navigate the newly opened file is likely result in nothing but a bunch of garbage characters inadvertently being typed at the top of the file (and losing the search location):

Note: this bug report is different than this (although perhaps it sounds superficially similar) feature request:

1 Like