Functions for doing case-persistant substitutions
Vim script
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a mirror of

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