17
submitted 3 months ago* (last edited 3 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.

top 10 comments
sorted by: hot top controversial new old
[-] KrankyKong@lemmy.world 5 points 3 months ago* (last edited 3 months ago)

At the system level I have Caps Lock mapped to Escape (because who doesn't), but I also have Caps Lock mapped to Control when I press it with another key, and I can press both shifts together to toggle Caps Lock.

At the Neovim level, I don't think I have anything ground breaking. Most of my keymaps I think are fairly standard within the community. But here's a couple of my more unique ones that I haven't seen many people use:

-- quick-switch buffer with TAB
keymap("n", "<TAB>", "<C-6>", opts)
-- Setup compilation keymap on fly
--
-- This one's actually pretty dope. 
-- Sometimes there's a command I want to run frequently, but it's not 
-- something I want to dedicate a permanent keymapping for because it's so 
-- specific to the task at hand. So this is keymap for creating another keymap
-- to run a terminal command with <leader>c
keymap("n", "<Leader>C", ":map <lt>leader>c :!<lt>cr><left><left><left><left>", {})

Oh, and here's some blasphemy for you, when I'm presenting I like to gesture with my mouse, or even sometimes just when I'm thinking through something. So I have keymaps in place to open my file explorer with right-click, or my harpoon window with middle-click. Then I have mouse keymaps in each of those windows to further navigate or select files with the mouse. Just makes navigating easier because I don't have to keep switching back to the keyboard (super fucking backwards, I know).

Here's my config in case anyone's interested. Maybe someone can find something useful in there. https://github.com/rnwtn/nvim-config/blob/master/lua/user/keymaps.lua

[-] dm319@feddit.uk 4 points 3 months ago

Yes, I also have caps mapped to esc, but done in keyboard firmware so that holding it functions as ctrl.

In neovim I have two escapes mapped to :noh

[-] 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 1 month 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 1 month ago
[-] KindaABigDyl@programming.dev 3 points 3 months ago

ctrl + x => :wqa

ctrl + s => :w

[-] dwraf_of_ignorance@programming.dev 3 points 3 months ago* (last edited 3 months ago)

leader to yank to the system ~~keyboard~~ clipboard

[-] ericjmorey@programming.dev 1 points 3 months ago

<leader> y will put your system clipboard into the unnamed register?

[-] TheLongPrice@lemmy.one 2 points 3 months ago

If you write blog posts, ss for spellcheck is nice

this post was submitted on 25 Jul 2024
17 points (100.0% liked)

Neovim

2155 readers
1 users here now

founded 1 year ago
MODERATORS