Easily swap the values in a ternary expression
example.mp4
javascript
javascriptreact
typescript
typescriptreact
c
cpp
c#
python
java
dart
swift
ruby
-- lazy.nvim
{ "xlboy/swap-ternary.nvim" }
Position the cursor over the ternary expression and then execute :lua require('swap-ternary').swap()
or :call swap_ternary#swap()
.
It's more convenient to define a keybinding with <leader>
.
In .vimrc
:
nnoremap <leader>S :call swap_ternary#swap()<CR>
" nnoremap <leader>S :lua require('swap-ternary').swap()<CR>
In init.lua
:
vim.api.nvim_set_keymap('n', '<leader>S', ':lua require("swap-ternary").swap()<CR>', { noremap = true, silent = true })
-- vim.api.nvim_set_keymap('n', '<leader>S', ':call swap_ternary#swap()<CR>', { noremap = true, silent = true })