vimtricks.wiki Concise Vim tricks, one at a time.

How do I uppercase text inside an HTML tag without changing the tags?

Answer

vitU

Explanation

When editing markup-heavy files, you often need to transform only the tag contents while preserving the surrounding structure. vitU is a compact, high-signal command chain for this: it selects inside the current tag and uppercases the selected text in one flow. This avoids fragile manual selections and keeps your edits structural.

How it works

  • v starts Visual mode
  • it expands the selection to the inner tag text object (content inside the nearest tag pair)
  • U uppercases the current Visual selection and returns to Normal mode

Because it is structural rather than positional, the command remains reliable even when the text length or indentation changes.

Example

Before (cursor anywhere inside alpha beta):

<p>alpha beta</p>

Run:

vitU

After:

<p>ALPHA BETA</p>

Tips

  • Use vat if you want to include the tag pair itself in the selection
  • The same pattern works with other Visual operators, such as vitgU or vit~ for different case transforms
  • If % jumps are inconsistent in HTML, ensure tag matching support is configured appropriately

Next

How do I convert all numbers to fixed-width zero-padded values in Vim?