mirror of
https://github.com/aquatix/dotfiles.git
synced 2025-12-07 00:05:10 +01:00
Toggle casing
This commit is contained in:
15
.vimrc
15
.vimrc
@@ -586,6 +586,21 @@ fun! TrimWhitespace()
|
|||||||
endfun
|
endfun
|
||||||
command! TrimWhitespace call TrimWhitespace()
|
command! TrimWhitespace call TrimWhitespace()
|
||||||
|
|
||||||
|
" Visually select text then press ~ to convert the text to UPPER CASE, then to lower case, then to Title Case.
|
||||||
|
" Keep pressing ~ until you get the case you want.
|
||||||
|
" https://vim.fandom.com/wiki/Switching_case_of_characters
|
||||||
|
function! TwiddleCase(str)
|
||||||
|
if a:str ==# toupper(a:str)
|
||||||
|
let result = tolower(a:str)
|
||||||
|
elseif a:str ==# tolower(a:str)
|
||||||
|
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
|
||||||
|
else
|
||||||
|
let result = toupper(a:str)
|
||||||
|
endif
|
||||||
|
return result
|
||||||
|
endfunction
|
||||||
|
vnoremap ~ y:call setreg('', TwiddleCase(@"), getregtype(''))<CR>gv""Pgv
|
||||||
|
|
||||||
" enable words completion
|
" enable words completion
|
||||||
set dictionary+=/usr/share/dict/words
|
set dictionary+=/usr/share/dict/words
|
||||||
" use ctrl-n ctrl-n instead of ctrl-x ctrl-k
|
" use ctrl-n ctrl-n instead of ctrl-x ctrl-k
|
||||||
|
|||||||
Reference in New Issue
Block a user