nvim-kickstart-python icon indicating copy to clipboard operation
nvim-kickstart-python copied to clipboard

Use keymap.set over cmd.inoreabbrev

Open emiasims opened this issue 2 years ago • 1 comments
trafficstars

'ia' as the mode is an insert mode abbreviation, since a while ago - not sure when exactly: vim.keymap.set('ia', '--', '#', { buffer = true })

Or if you want to have fun,

vim.iter {
  true = 'True',
  false = 'False',
  ['--'] = '#',
  null = 'None',
  none = 'None',
  nil = 'None',
}:each(function(lhs, rhs)
  vim.keymap.set('ia', lhs, rhs, { buffer = true })
end)

Or

local iabbrev = function(lhs, rhs)
  vim.keymap.set('ia', lhs, rhs, { buffer = true })
end
iabbrev('true', 'True')
iabbrev('false', 'False')
iabbrev('--', '#')
iabbrev('null', 'None')
iabbrev('none', 'None')
iabbrev('nil', 'None')

emiasims avatar Sep 27 '23 11:09 emiasims

oh nice, I didn't know about that one.

Could it be that you are on nightly though? I am on 0.9.2, and trying ia as mode results in an error for me


edit: yep, it's only supported on nightly

I will probably leave at as vim.cmd.iabbr until around nvim 0.11.

chrisgrieser avatar Sep 27 '23 12:09 chrisgrieser

Update to using keymap.set as nvim 0.10 has been released.

(Not using vim.iter to keep it simple for new users :) )

chrisgrieser avatar May 22 '24 10:05 chrisgrieser