Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Found this site:

And it works for the first character but my lines are line this

this_is_a_string

And I would like this

This_Is_A_String

Any thoughts?

VI Command would be nice but any other simple solution would work as well

share|improve this question
up vote 7 down vote accepted

do :%s/^./\U&/ then :%s/_./\U&/g

the first will uppercase the first letter of every line, the second will uppercase the first letter after each underscore in all lines.

share|improve this answer

Combining the two search/replace Rob suggested:

:%s/^.\|_./\U&/gc

will search for either the first char in a line or the first char following an _.

Explanation:

  • \| specifies 'or'
  • g will change all occurrences in a line
  • c will ask for confirmation
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .