Home

Awesome

nvim-toggler

Invert text in vim, purely with lua.

demo

Install  ·  Run  ·  Custom inverses  ·  Custom keymaps

Install

Using packer.nvim

use { 'nguyenvukhang/nvim-toggler' }

Using vim-plug

Plug 'nguyenvukhang/nvim-toggler'

Run

-- init.lua
require('nvim-toggler').setup()
" init.vim or .vimrc
lua << EOF
require('nvim-toggler').setup()
EOF

Once that is set, the default binding is <leader>i to invert the word under your cursor.

Custom inverses

You can configure nvim-toggler with the setup() function:

-- init.lua
require('nvim-toggler').setup({
  -- your own inverses
  inverses = {
    ['vim'] = 'emacs'
  },
  -- removes the default <leader>i keymap
  remove_default_keybinds = true,
  -- removes the default set of inverses
  remove_default_inverses = true,
  -- auto-selects the longest match when there are multiple matches
  autoselect_longest_match = false
})

Custom keymaps

To map toggling to something else like <leader>cl, simply do

-- init.lua
vim.keymap.set({ 'n', 'v' }, '<leader>cl', require('nvim-toggler').toggle)