> ~ biozz / Blog

New series: NeoVim config 2023-07-20

Starting a new series about the evolution of my NeoVim config

Reading time: 2m (375 words)

I reallised that I spend quite a lot of time on NeoVim’s subreddit and that it is a constant source of inspiration on how to improve my config and try something new. I am constantly tweaking my config, adding things and trying to break some of the muscle memory I have developed over the years. And I want to share my experiences with the world and my future self.

So I am starting a new series - NeoVim Config.

It will mainly focus on the changes in my init.lua. I also have the concept of a Plugin Graveyard, where I collect stuff that I don’t use anymore, together with configs, that didn’t work out for me.

Let’s start the series with the latest hot topic: Which key do you prefer for exiting insert mode in Neovim?

Trying out <Esc> alternatives

jk looked like a less intrusive solution, so I started with it.

I added max397574/better-escape.nvim and used the config, which the author suggested in the readme:

require("better_escape").setup {
    mapping = {"jk"},
    timeout = vim.o.timeoutlen,
    clear_empty_lines = false,
    keys = function()
      return vim.api.nvim_win_get_cursor(0)[2] > 1 and '<esc>l' or '<esc>'
    end,
}

This keys function part messed up my status line, so I had to go back to:

keys = "<Esc>"

It felt very weird and I also noticed, that it didn’t work when I switched to the Cyrillic keyboard layout, so I added it:

mapping = {"jk", "ол"},

Then I reallised that I could not use jk for other scenarios, where I would normally use Esc:

  • quitting command mode
  • closing popups

It quickly started to feel inconsistent.

So I listened to the other top comments and tried Ctrl+[. The funny thing is that it works out of the box without any additional configuration or plugins.

It is still very weird and I have to remind myself to not hit the Esc button, but it works.

Plugin Graveyard

Today we welcome our latest new friend, who passed away quickly after entering the config - max397574/better-escape.nvim.

It had very nice minimalist configuration and taught us once again that sometimes you don’t need the plugin to do the job well.

require("better_escape").setup({
	mapping = { "jk", "ол" },
	timeout = vim.o.timeoutlen,
	clear_empty_lines = false,
    keys = "<Esc>"
})

Farewell, better-escape.nvim.

More posts in NeoVim Config series:

There is nothing in here at the moment