aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-09-09 22:52:15 +0000
committerJosh Rahm <rahm@google.com>2022-09-09 22:52:15 +0000
commitdb244c14b65313e66141095a051ac49fd2871596 (patch)
tree1a7537e5f0a5f18664d89c03290a8b1edd4b73b1
parent0b9d3d53b776d0f6128c64e8b73557b137d88e4c (diff)
downloadfieldmarshal.vim-db244c14b65313e66141095a051ac49fd2871596.tar.gz
fieldmarshal.vim-db244c14b65313e66141095a051ac49fd2871596.tar.bz2
fieldmarshal.vim-db244c14b65313e66141095a051ac49fd2871596.zip
casefmt.vim: add lower/upper case formats with u/U
-rw-r--r--plugin/casefmt.vim16
1 files changed, 15 insertions, 1 deletions
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 <SID>case_substitute(<line1>, <line2>, <f-args>)