nguyenvukhang/nvim-toggler

github github
utility
stars 138
issues 1
subscribers 1
forks 3
CREATED

2022-08-16

UPDATED

3 months ago


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,
})

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)