Plug 'axlebedev/vim-chase'
vim9script
Chase: Change case
vim-chase.webm
- Place cursor at word, or visual select text (no multiline selections)
- Press
~
(one or several times).
Supported cases:
Case name | Example |
---|---|
title |
Hello Vim World |
camel |
helloVimWorld |
pascal |
HelloVimWorld |
lower_dash |
hello-vim-world |
lower_space |
hello vim world |
lower_underscore |
hello_vim_world |
upper_dash |
HELLO-VIM-WORLD |
upper_underscore |
HELLO_VIM_WORLD |
upper_space |
HELLO VIM WORLD |
password |
************* |
Disable default mappings: g:chaseMapDefault = false
nnoremap ~ <ScriptCmd>chase.Next()<cr>
vnoremap ~ <ScriptCmd>chase.Next()<cr>
nnoremap ! <ScriptCmd>chase.Prev()<cr>
vnoremap ! <ScriptCmd>chase.Prev()<cr>
Is default mappings been set by default or not.
Bool
Default: true
let g:chaseMapDefault = false
Time to highlight chase.
Set 0 to disable highlight.
Number milliseconds.
Default: 2000
let g:chaseHighlightTimeout = 700
Only for title
, camel
and pascal
cases.
Define how to deal with abbreviations or uppercased sections:
Example
Example: `g:chaseRespectAbbreviation = true`: `'sendSMSMessage' => 'SendSMSMessage' => 'Send SMS Message'` `g:chaseRespectAbbreviation = false`: `'sendSMSMessage' => 'sendSmsMessage' => 'Send Sms Message'`Bool
Default: true
let g:chaseRespectAbbreviation = false
Order, in which single-letter cases will be passed through, starting from current letter's case If current case is undefined - start from beginning of list
list<string>, array of case names
Default: ['upper', 'lower']
let g:chaseLetterCasesOrder = ['upper']
Order, in which single-word cases will be passed through, starting from current word's case If current case is undefined - start from beginning of list
list<string>, array of case names
Default: ['upper', 'lower', 'title']
let g:chaseWordCasesOrder = ['upper']
Order, in which multi-word cases will be passed through, starting from current word's case If current case is undefined - start from beginning of list
list<string>, array of case names
Default:
[
'camel',
'pascal',
'lower_space',
'lower_dash',
'lower_underscore',
'upper_underscore',
'upper_dash',
'upper_space',
'title',
]
let g:chaseSentenceCasesOrder = ['upper_underscore', 'camel']
Customize colors for chased word:
highlight ChaseWord guibg=#532120 guifg=NONE
or
highlight link ChaseChangedLetter Search
ChaseWord
Color for whole chased word.
Default: same as 'Pmenu' highlight group
ChaseChangedLetter
Colors for those letters that were changed
Default: same as 'Search' highlight group
ChaseSeparator
Colors for those 'separator' characters of current case
Default: same as 'ChaseChangedLetter' highlight group
:ChaseNext
:ChasePrev
Run "chase": change current word's case to next or prev.
:ChasePrintAllCases
Print all case names to 'echom'
import 'chase.vim' as chase
chase.Next(options = {})
chase.Prev(options = {})
Run "chase": change current word's case to next or prev.
options
is map, where you can pass any of configuration options only for one run.
It may include following configuration options:
chaseRespectAbbreviation
chaseSentenceCasesOrder
chaseWordCasesOrder
chaseLetterCasesOrder
chaseHighlightTimeout
Example
chase.Next()
- simple run, without any customizations. Use global options
chase.Next({chaseRespectAbbreviation: false})
- simple run, but all abbreviations will be chased as usual word
chase.Next({chaseWordCasesOrder: ['upper'], chaseSentenceCasesOrder: ['upper_underscore']})
- replace any variable with CONSTANT_CASE
chase.PrintAllCases()
Print all availble case names.
Plugin was originally forked from 'vim-case-change'.
If you find a bug, want to add new case, or have an improvement suggestion -
please place an issue in this repository.
Check out my Vim plugins:
https://github.com/axlebedev