17
submitted 4 months ago* (last edited 4 months ago) by ericjmorey@programming.dev to c/neovim@programming.dev

It's broader than a Neovim specific mapping, I've changed the system keyboard mapping of <Caps Lock> to <Esc> and <F9> to <Caps Lock>.

I think mapping <Caps Lock> to <Esc> isn't uncommon for Neovim users. But I like having <Caps Lock> available for non Neovim purposes.

you are viewing a single comment's thread
view the rest of the comments
[-] dm319@feddit.uk 2 points 3 months ago* (last edited 3 months ago)

Just to clarify - means two taps of the esc key in succession will clear highlighting (ps I'm curious how other people do it!).

nmap <esc><esc> :noh<return>

[-] sik0fewl@lemmy.ca 2 points 2 months ago

Here's what I do. Any search key will turn hlsearch on and will turn it off.

vim.on_key(function(char)
  if vim.fn.mode() == "n" then
    local new_hlsearch = vim.tbl_contains({ "<CR>", "n", "N", "*", "#", "?", "/" }, vim.fn.keytrans(char))
    local esc = vim.tbl_contains({ "<Esc>" }, vim.fn.keytrans(char))

    if new_hlsearch then
      vim.opt.hlsearch = true
    elseif esc then
      vim.opt.hlsearch = false
    end
  end
end, vim.api.nvim_create_namespace("auto_hlsearch"))
[-] dm319@feddit.uk 1 points 2 months ago
this post was submitted on 25 Jul 2024
17 points (100.0% liked)

Neovim

2178 readers
2 users here now

founded 1 year ago
MODERATORS