1

I really like Neovim to take notes but there are a lot of friction points when you stay a long time in insert mode.. Anyway, the current problem is that I can't jump lines like in normal mode...

I want to move it like this gj or gk instead of h,j,k,l but in INSERTMODE !

I tried this:

vim.api.nvim_set_keymap("i", "<Up>", "<ESC>gki", {})

vim.api.nvim_set_keymap("i", "<Down>", "<ESC>gji", {})

But its not a nice solution because I jump out of insert mode when I press fast... Is there a solution to this problem ?

2
  • Resist the temptation to stay in Insert mode: vimcasts.org/episodes/modal-editing-undo-redo-and-repeat
    – D. Ben Knoble
    Feb 9 at 14:41
  • Great video. Just to explain myself a bit more.. I just dive in into each mode and adjust small details that I find.. Like in this video there were talking about short keystrokes... You can also make an undo command more specific with this: ``` keymap("i", "<space>", "<space><c-g>u", opts) --undo per word keymap("i", "<tab>", "<tab><c-g>u", opts) --undo per tab keymap("i", "<enter>", "<enter><c-g>u", opts) ``` This can also safe some time ;) Of curse I train myself in normal mode. I want to be fast. Feb 10 at 15:51

1 Answer 1

2

I would do:

vim.api.nvim_set_keymap("i", "<Up>", "<C-o>gk", {})

vim.api.nvim_set_keymap("i", "<Down>", "<C-o>gj", {})

In insert mode the Ctrl o allows you to run one key command of Normal mode. Vim automatically switch back to Insert mode right after.

3
  • Amazing, Thx :D Feb 9 at 9:31
  • 1
    Thanks for the feedback :-) You are are welcome. That being said staying in insert mode for a long time is not what most Vim users are doing. You are doomed to be an exotic user that could make your life difficult ;-) Feb 9 at 9:36
  • 1
    Just starting.. give me some time ;) Feb 9 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.