nguyenvukhang/nvim-toggler

github github
utility
star 51
stars
alert-circle 2
open issues
users 1
subscribers
git-branch 5
forks
CREATED

2022-08-16

UPDATED

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

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)