sponsor Vim development Vim logo Vim Book Ad

CtrlXA : make Ctrl-X and Ctrl-A run through keyword cycles

 script karma  Rating 1/1, Downloaded by 122  Comments, bugs, improvements  Vim wiki

created by
Enno Nagel
 
script type
utility
 
description
This Vim plug-in makes the key bindings `<Ctrl-X/A>` additionally cycle through lists of keywords such as `true/false`, `yes/no`, `set/unset` or `yesterday/today/tomorrow`.Useful, for example,

- for toggling settings in a configuration file, or
- for switching between `pick`, `squash`, `reword`, ... a `git` commit when rebasing.

These keywords are configurable by the variable g:CtrlXA_Toggles which defaults to

  let g:CtrlXA_Toggles = [
      \ ['true', 'false'], ['True', 'False'], ['TRUE', 'FALSE'],
      \ ['yes', 'no'], ['Yes', 'No'], ['YES', 'NO'],
      \ ['on', 'off'], ['On', 'Off'], ['ON', 'OFF'],
      \ ['up', 'down'], ['Up', 'Down'] ,['UP', 'DOWN'],
      \ ['set', 'unset'],
      \ ['is', 'isnot'] ,
      \ ['==', '!='] , ['<', '>'], ['<=', '>='], ['=~', '!~'],
      \ ['enable', 'disable'], ['Enable', 'Disable'],
      \ ['enabled', 'disabled'], ['Enabled', 'Disabled'],
      \ ['maximum', 'minimum'], ['Maximum', 'Minimum'],
      \ ['maximal', 'minimal'], ['Maximal', 'Minimal'],
      \ ['upper', 'lower'], ['Upper', 'Lower'],
      \ ['top', 'bottom'], ['Top', 'Bottom'],
      \ ['above', 'below'], ['Above', 'Below'],
      \ ['forward', 'backward'], ['Forward', 'Backward'],
      \ ['right', 'middle', 'left'], ['Right', 'Middle', 'Left'],
      \ ['next', 'previous'], ['Next', 'Previous'],
      \ ['first', 'last'], ['First', 'Last'],
      \ ['before', 'after'], ['Before', 'After'],
      \ ['more', 'less'], ['More', 'Less'],
      \ ['fast', 'slow'], ['Fast', 'Slow'],
      \ ]

There is also its buffer-local analogue, which allows for file-type specific
keyword cycles by, for example

  autocmd FileType gitrebase
              \ let b:CtrlXA_Toggles = [
              \ ['pick', 'fixup', 'squash', 'break', 'reword', 'edit', 'drop'],
              \ ] + g:CtrlXA_Toggles
  autocmd FileType vim
              \ let b:CtrlXA_Toggles = [
              \ ['if', 'else', 'elseif', 'endif'],
              \ ] + g:CtrlXA_Toggles
  autocmd FileType sh
              \ let b:CtrlXA_Toggles = [
              \ ['if', 'elif', 'else', 'fi'],
              \ ] + g:CtrlXA_Toggles
  autocmd FileType tex
              \ let b:CtrlXA_Toggles = [
              \ ['final', 'draft'],
              \ ['|', '\nmid'], ['=', '\neq'], \
              \ ['\leq', '\geq],
              \ ] + g:CtrlXA_Toggles

This will

- include all keyword cycles of the global variable, and
- add (buffer-)local keyword cycles which have precedence over the global cycles.

There are many more toggles that could be useful, for example, to switch between the draft and final version of a `TeX` document, add:

  autocmd FileType tex
              \ let b:CtrlXA_Toggles = [
              \ ['final', 'draft'],
              \ ] + g:CtrlXA_Toggles

vim-CtrlXA is developed at https://github.com/Konfekt/vim-CtrlXA where issues can be filed.
 
install details
unzip vim-CtrlXA.zip into ~/.vim (respectivley %USERPROFILE/_vim in Microsoft Windows).
 

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
vim-CtrlXA.zip 1.3 2018-12-06 6.0 Enno Nagel more default lists
vim-CtrlXA.zip 1.2 2017-08-31 5.7 Enno Nagel allow for non-keyword characters
vim-CtrlXA.zip 1.1 2017-08-29 5.7 Enno Nagel Support file-type specific keyword cycles.
vim-CtrlXA.zip 1.0 2017-08-26 5.7 Enno Nagel Initial upload
ip used for rating: 52.91.245.237

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.
   
OSDN.net Logo