sponsor Vim development Vim logo Vim Book Ad

Toggle : allows you to toggle bool (true/false) and other words with a shortcut

 script karma  Rating 115/46, Downloaded by 1700    Comments, bugs, improvements  Vim wiki

created by
Timo Teifel
 
script type
utility
 
description
In this version, the script can toggle:
    true     <->     false
    on       <->     off
    yes      <->     no
    define  <->     undef
    +        <->     -
    >        <->     <
    &&    <->     ||
    &     <->      |
    positive and negative numbers

Move the cursor on the word/char/number to be toggled and press
      <C-T>  in insert mode
or
      +     in normal / visual mode.

This shortcut can be modified in the script file - of course...

If the cursor is positioned on a number, the script looks for a corresponding + or - sign for that number.
If it's found, it will be replaced by the other one. If none is found, a - sign is inserted before the number.
 
install details
put this plugin into your ~/.vim/plugin folder or source it in your ~/.vimrc
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
toggle.vim 0.5 2010-09-15 7.0 Timo Teifel - Keeps the keyword case when toggling (thanks to Jan Christoph Ebersbach for this code)
- bugfix for && and || toggling
toggle.vim 0.4 2010-09-14 7.0 Timo Teifel default mapping uses + in normal and visual mode instead of <C-T>
added toggle entries: && <--> ||   and & <--> |
internal optimizations
toggle.vim 0.3 2004-02-06 6.0 Timo Teifel I added define/undef as new words.
I added a mapping for visual mode (it actually quits visual mode and calls the Toggle function. But now it works, if you clicked with the mouse on the word and accidentally switched on visual mode...)
I realised that <C-S-T> is the same than <C-T> I didn't intent to break these mappings, but since I didn't find another suitable keymapping, I now use <C-T>. Anyone who doesn't like that can change that easily.
toggle.vim 0.2 2004-02-02 6.0 Timo Teifel Initial upload
ip used for rating: 54.234.217.88

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo