Toggle a word under the cursor to its 'opposite value', e.g. True
-> False
.
With packer:
use({
"al-ce/opptogg.nvim",
config = function()
require('opptogg').setup({
-- config or leave empty for defaults
})
end
})
Set the cursor over a word in OppTogg's table and execute :OppTogg
to
substitute its 'opposite'. The cursor remains in its current position.
Example (where *
denotes cursor position):
Before | After
------------------|--------------------
if foo == tr*ue: | if foo == fa*lse:
This shows the default configuration. Passing a new table to opp_table
will
override the default table completely.
No mapping is set by default. Set a mapping for :OppTogg
on your own or set
a string value in mapping
to have the config do it for you.
require('opptogg').setup({
opp_table = {
["True"] = "False",
["true"] = "false",
["0"] = "1",
["yes"] = "no",
["Yes"] = "No",
["foo"] = "bar",
["var1"] = "var2",
},
mapping = '', -- I use <leader>` since ` toggles upper/lower case.
})
Currently, only words with characters matched by the regex \k
can be toggled.
This excludes symbols like +-*/=~!
and spaces.
cursor-word.nvim for the code to match the word under the cursor.