This is a minimal Neovim plugin that can be used to toggle various boolean-like values.
The toggles included by default are:
False
←→True
false
←→true
The toggle works for the first match on the current line starting at the cursor position.
Additional toggles can be setup by the user.
This plugin is a Lua port of the Vim version gerazov/vim-toggle-bool.
The plugin can be installed via a plugin manager.
For packer.nvim it's:
use 'gerazov/toggle-bool.nvim'
To setup the plugin run:
require("toggle-bool").setup {
mapping = "<leader>tt",
additional_toggles = {
Yes = 'No',
On = 'Off',
["0"] = "1",
Enable = 'Disable',
Enabled = 'Disabled',
First = 'Last',
Before = 'After',
Persistent = 'Ephemeral',
Internal = 'External',
Ingress = 'Egress',
Allow = 'Deny',
All = 'None',
},
}
The plugin exposes a single function toggle_bool
that is mapped to the specified mapping
.
Alternatively, it can be called via:
:lua require("toggle-bool").toggle_bool()
- rmagatti/alternate-toggler - a bit heavier, toggles current word under cursor via yanking
- monaqa/dial.nvim - a more powerful cycler plugin supporting dates, colors etc.
- johmsalas/shake.nvim - a more general purpose string transformation plugin that can be used for toggling booleans
- gerazov/vim-toggle-bool - VIML toggler based on
switch.vim
- AndrewRadev/switch.vim - a powerful general purpose string transformation plugin