Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (23 sloc) 999 Bytes
This is a mirror of http://www.vim.org/scripts/script.php?script_id=6
Usage: Using KeepCase or KeepCaseSameLen defined here, do a substitution like this:
%s/\u\<old_word\>/\=KeepCaseSameLen(submatch(0), 'new_word')/g
* KeepCase( original_word , new_word )
returns the new word maintaining case
simply uses heuristics to work out some different common situations
given NewWord
Word --> Newword
WORD --> NEWWORD
word --> newword
WoRd --> NewWord
woRd --> newWord
* KeepCaseSameLen( original_word , new_word )
Returns the new word maintaining case
Keeps the case exactly the same letter-for-letter
It does work if the words aren't the same length, as it truncates or
just coppies the case of the word for the length of the original word.
* :SubstituteCase#\ctoto\(Titi\)tata#\1Tutu#g
totoTitiTata -> titiTutu
TotoTitiTata -> TitiTutu
tototititata -> tititutu
tototitiTata -> titiTutu
TototitiTata -> TitiTutu