Skip to content

xlboy/swap-ternary.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌪️swap-ternary.nvim

Easily swap the values in a ternary expression

example.mp4

Supported languages

  • javascript
  • javascriptreact
  • typescript
  • typescriptreact
  • c
  • cpp
  • c#
  • python
  • java
  • dart
  • swift
  • ruby

Install

-- lazy.nvim
{ "xlboy/swap-ternary.nvim" }

How to use?

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