From db244c14b65313e66141095a051ac49fd2871596 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 9 Sep 2022 22:52:15 +0000 Subject: casefmt.vim: add lower/upper case formats with u/U --- plugin/casefmt.vim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/casefmt.vim b/plugin/casefmt.vim index 8471578..4c66a76 100644 --- a/plugin/casefmt.vim +++ b/plugin/casefmt.vim @@ -21,6 +21,8 @@ " t - title case " T - Title Case " - - dashed-case +" u - lowercase +" U - UPPERCASE if ! exists('g:casefmt_include_bindings') let g:casefmt_include_bindings = 1 @@ -40,7 +42,9 @@ let s:case_fmts = { \ 'K': 'to_CONSTANT_space', \ 't': 'to_title', \ 'T': 'to_Title', - \ '-': 'to_dashed' + \ '-': 'to_dashed', + \ 'u': 'to_lower', + \ 'U': 'to_upper' \ } function! CaseFmt_AddFormat(key, funcname) abort @@ -167,6 +171,14 @@ function! s:to_Title(s) abort return substitute(s:to_title(a:s), '\<[a-z]', '\u\0', 'g') endfunction +function! s:to_lower(s) abort + return tolower(substitute(a:s, '_', '', 'g')) +endfunction + +function! s:to_upper(s) abort + return toupper(substitute(a:s, '_', '', 'g')) +endfunction + function! s:to_dashed(s) abort return substitute(a:s, '_', '-', 'g') endfunction @@ -230,5 +242,7 @@ endfunction " [t]itle case " [K]ONSTANT CASE " [-]dashed-case +" [U]PPERCASE +" [u]lowercase command! -range -nargs=+ CaseSubstitute \ call case_substitute(, , ) -- cgit