Replace uppercase with lowercase letters
Categories:
Converting Uppercase to Lowercase in Sublime Text

Learn various methods to quickly change the case of text from uppercase to lowercase within Sublime Text, enhancing your text editing efficiency.
Sublime Text is a powerful and versatile code editor that offers numerous features to streamline your workflow. One common task for developers and writers is changing the case of text, such as converting all uppercase letters to lowercase. This article will guide you through several efficient methods to achieve this in Sublime Text, from built-in commands to regular expressions.
Using Built-in Case Conversion Commands
Sublime Text provides direct commands for case conversion, making it the simplest method for most users. These commands are accessible via the menu or keyboard shortcuts.
1. Select the Text
Highlight the portion of text you wish to convert to lowercase. If no text is selected, the command will typically apply to the entire line where the cursor is positioned.
2. Access the 'Transform' Menu
Navigate to Edit
> Permute Lines
> Transform
in the Sublime Text menu bar.
3. Choose 'Lowercase'
From the Transform
submenu, select Lowercase
. Your selected text will instantly be converted to lowercase.
Ctrl+K, Ctrl+L
on Windows/Linux or Cmd+K, Cmd+L
on macOS. This two-step shortcut means you press Ctrl+K
(or Cmd+K
), release, then press Ctrl+L
(or Cmd+L
).Converting Case with Find and Replace (Regular Expressions)
For more advanced or conditional case conversions, Sublime Text's Find and Replace feature, combined with regular expressions, offers greater flexibility. This method is particularly useful when you need to convert specific patterns or parts of a string.
flowchart TD A[Open Find/Replace] --> B{Enable Regex} B --> C[Enter Find Pattern] C --> D[Enter Replace Pattern] D --> E[Click 'Replace All'] E --> F[Text Converted]
Workflow for converting case using Find and Replace with Regular Expressions.
1. Open Find and Replace
Press Ctrl+H
(Windows/Linux) or Cmd+Option+F
(macOS) to open the Find and Replace panel.
2. Enable Regular Expressions
Click the .*
icon (usually the leftmost icon) in the Find and Replace panel to enable regular expression matching.
3. Define Find and Replace Patterns
In the 'Find' field, enter ([A-Z])
. This pattern captures any single uppercase letter.
In the 'Replace' field, enter \L$1
. Here, \L
converts the captured group ($1
) to lowercase.
4. Execute Replacement
Click the Replace All
button to convert all matching uppercase letters to lowercase throughout your document.
Find: ([A-Z])
Replace: \L$1
Regular expression for converting all uppercase letters to lowercase.
Replace All
with regular expressions, especially in large files. Always save your work before performing a global replacement, or test it on a small selection first.Converting Specific Words or Phrases
If you only need to convert specific words or phrases, you can adapt the regular expression approach. For instance, to convert only words that are entirely uppercase.
Find: \b([A-Z]+)\b
Replace: \L$1
Regular expression to convert entire uppercase words to lowercase.
In this example, \b
matches a word boundary, and [A-Z]+
matches one or more uppercase letters. This ensures that only whole words consisting solely of uppercase letters are converted.