Skip to content

bootleq/vim-cycle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cycle.vim

Cycle text within predefined candidates.

  • yes => no => yes
  • January => February => March
  • trUe => faLse   keep case by default
  • " => '   can handle non-keywords
  • => 可   multibyte is fine
  • Rails Metal => Thrash => Technical Death   handle multi-words by visual selection, or smart auto search
  • <em>important</em> => <strong>important</strong>   tag pairs cycle together
  • quoted => quoted   special pairs cycle together

Configuration Example

let g:cycle_no_mappings = 1
let g:cycle_max_conflict = 14
let g:cycle_select_ui = 'ui.select'
let g:cycle_conflict_ui = 'confirm'

nmap <silent> <LocalLeader>a <Plug>CycleNext
vmap <silent> <LocalLeader>a <Plug>CycleNext
nmap <silent> <Leader>a <Plug>CyclePrev
vmap <silent> <Leader>a <Plug>CyclePrev
nmap <silent> <LocalLeader>ga <Plug>CycleSelect
vmap <silent> <LocalLeader>ga <Plug>CycleSelect

let g:cycle_default_groups = [
      \   [['true', 'false']],
      \   [['yes', 'no']],
      \   [['on', 'off'], 'match_word'],
      \   [['+', '-']],
      \   [['>', '<']],
      \   [['"', "'"]],
      \   [['==', '!='], { 'cond': function('s:not_lua_context') }],
      \   [['0', '1']],
      \   [['and', 'or']],
      \   [['asc', 'desc']],
      \   [['', '']],
      \   [['', '']],
      \   [['', '', '']],
      \   [['', '', '', '', '', '', '', '']],
      \   [['lat', 'lon'], 'match_word'],
      \   [['latitude', 'longitude']],
      \   [['ancestor', 'descendant']],
      \   [['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
      \     'Friday', 'Saturday'], ['hard_case', {'name': 'Days'}]],
      \   [['(:)', '(:)', '「:」', '『:』'], 'sub_pairs'],
      \ ]

" For fileType "lua" only
let g:cycle_default_groups_for_lua = [
      \   [['==', '~=']],
      \ ]

" For fileType "plaintex" only
let g:cycle_default_groups_for_plaintex = [
      \   [
      \     '\left(:\right)',
      \     '\mleft(:\mright)',
      \     '\Bigl(:\Bigr)',
      \     '(:)',
      \   ],
      \   'sub_pairs', 'hard_case', 'match_case'
      \ ]
      " Note (:) must be put at the end. The search runs in sequence,
      " an earlier ( match can short-circuit the following items.

" For HTML, but here just blindly add to global groups
let g:cycle_default_groups += [
      \   [['h1', 'h2', 'h3', 'h4'], 'sub_tag'],
      \   [['ul', 'ol'], 'sub_tag'],
      \   [['em', 'strong', 'small'], 'sub_tag'],
      \ ]

let g:cycle_default_groups += [
      \   [['', '', '', '', '', '', '']],
      \   [['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']],
      \   [['January', 'February', 'March', 'April', 'May', 'June', 'July',
      \     'August', 'September', 'October', 'November', 'December']],
      \   [['portrait', 'landscape']],
      \ ]

Similar Projects

  • SwapIt by Michael Brown
    Original ideas of special features including visual multi-words, xml tag pairs, omni-complete cycling.

  • Cycle.vim by Zef
    Yes, there is already a plugin named 'Cycle'. Maybe I have to rename mine.

  • switch.vim by AndrewRadev
    Supports more complicated patterns like ruby :a => 'b' to a: 'b', which is generally unable to achieve by alternative projects.

  • vim-clurin by syngan
    Another early implementation, seems to have custom pattern and replace function features, but lacks documentation.

  • toggle.vim by Timo Teifel
    Maybe the very first plugin that introduced this idea.

Blog Posts

TODO

wiki/TODO

Development

Test

Run the test scripts, will clone vim-themis and execute it.

make test

Or directly run:

./test/run.sh
THEMIS_VIM=nvim ./test/run.sh
./test/run.sh --reporter dot --target 'respects .match_case"'
./test/run.sh --help

About

Cycle text within predefined candidates.

Resources

Stars

Watchers

Forks

Packages

No packages published