How do I change the case of a string using the “:substitute”

command? You can use special characters in the replacement string for a “:substitute” command to change the case of the matched string. For example, to change the case of the string “MyString” to all uppercase, you can use the following command:

    :%s/MyString/\U&/g

To change the case to lowercase, you can use the following command:

    :%s/MyString/\L&/g

To change the case of the first character in all the words in the current line to uppercase, you can use the following command:

    :s/\<\(.\)\(\k*\)\>/\u\1\L\2/g

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind