Skip to content

a neovim plugin that can easily switch words, such as switch 'true' to 'false'

License

Notifications You must be signed in to change notification settings

tandy1229/wordswitch.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordSwitch.nvim

A simple word switch plugin with neovim

Example

WordSwitch.nvim is a simple plugin for Neovim

A rewrite of Antovim use Lua

Table of contents

Requirements

WordSwitch.nvim require Neovim version 0.7 or above

Installation

If you are using vim-plug or packer.nvim, then add one of the following line to your init.vim or init.lua file, correspodingly:

" vim-plug
Plug 'tandy1229/wordswitch.nvim'

" packer.nvim
use 'tandy1229/wordswitch.nvim'

For lazy.nvim:

-- lazy.nvim
{ 'tandy1229/wordswitch.nvim' },

Or you can use other plugin manager.

Quick Start

The plugin provides a single command WordSwitch, which will replace the word under the matching word within a list of substitutions. eg, with your cursor over the word true will switch to false.

Note

now you can also switch TRUE to FALSE and switch True to False!!

It works for all other dictionaries!

The default mapping is gs to switch the word.

Change keymap

You can change the default keymap gs to your prefer, for example:

For init.vim user, you can add it into your init.vim:

let g:wordswitch_keymap = '<Leader>s'

For init.lua user, you can add it to your init.lua:

vim.g.wordswitch_keymap = '<Leader>s'

Custom list

You can customize your own list, use g:custom_wordswitch_definitions to add your own list, for example:

For init.vim user, you can add it into your init.vim:

let g:custom_wordswitch_definitions = [
\  [ 'let', 'unlet' ],
\  [ 'thx', 'thank you'],
\  [ 'under', 'below', 'beneath']
]

For init.lua user, you can add it to your init.lua:

vim.g.custom_wordswitch_definitions = {
    { 'let', 'unlet' },
    { 'thx', 'thank you' },
    { 'under', 'below', 'beneath' }
}

Source Word

The default words list are beneath:

{ 'acquire'   , 'release'      }
{ 'add'       , 'remove'       }
{ 'advance'   , 'retreat'      }
{ 'allocate'  , 'deallocate'   }
{ 'allow'     , 'deny'         }
{ 'assemble'  , 'disassemble'  }
{ 'assign'    , 'deassign'     }
{ 'associate' , 'dissociate'   }
{ 'attach'    , 'detach'       }
{ 'begin'     , 'end'          }
{ 'bind'      , 'unbind'       }
{ 'commit'    , 'rollback'     }
{ 'compile'   , 'decompile'    }
{ 'compose'   , 'parse'        }
{ 'compress'  , 'decompress'   }
{ 'connect'   , 'disconnect'   }
{ 'construct' , 'destruct'     }
{ 'create'    , 'destroy'      }
{ 'do'        , 'undo'         }
{ 'enable'    , 'disable'      }
{ 'encode'    , 'decode'       }
{ 'encrypt'   , 'decrypt'      }
{ 'enqueue'   , 'dequeue'      }
{ 'enter'     , 'leave'        }
{ 'expand'    , 'collapse'     }
{ 'first'     , 'last'         }
{ 'freeze'    , 'unfreeze'     }
{ 'front'     , 'back'         }
{ 'get'       , 'set'          }
{ 'grant'     , 'revoke'       }
{ 'head'      , 'tail'         }
{ 'high'      , 'low'          }
{ 'import'    , 'export'       }
{ 'include'   , 'exclude'      }
{ 'increase'  , 'decrease'     }
{ 'increment' , 'decrement'    }
{ 'indent'    , 'dedent'       }
{ 'inflate'   , 'deflate'      }
{ 'inject'    , 'eject'        }
{ 'input'     , 'output'       }
{ 'insert'    , 'delete'       }
{ 'install'   , 'uninstall'    }
{ 'left'      , 'right'        }
{ 'Left'      , 'Right'        }
{ 'link'      , 'unlink'       }
{ 'load'      , 'unload'       }
{ 'lock'      , 'unlock'       }
{ 'max'       , 'min'          }
{ 'maximum'   , 'minimum'      }
{ 'new'       , 'old'          }
{ 'next'      , 'previous'     }
{ 'open'      , 'close'        }
{ 'off'       , 'on'           }
{ 'paste'     , 'cut'          }
{ 'push'      , 'pop'          }
{ 'read'      , 'write'        }
{ 'reference' , 'dereference'  }
{ 'register'  , 'deregister'   }
{ 'resume'    , 'suspend'      }
{ 'select'    , 'deselect'     }
{ 'send'      , 'receive'      }
{ 'serialize' , 'deserialize'  }
{ 'set'       , 'get'          }
{ 'show'      , 'hide'         }
{ 'start'     , 'stop'         }
{ 'true'      , 'false'        }
{ 'up'        , 'down'         }
{ 'upper'     , 'lower'        }

Star History

Star History Chart

Credit

LICENSE

MIT

About

a neovim plugin that can easily switch words, such as switch 'true' to 'false'

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages