Sublime Text: Handling Multiple Selections Indent Level

Abstract: Resolve inconsistent indentation across multiple lines in Sublime Text by using Tab and Shift+Tab with multiple cursors to apply uniform formatting efficiently.

Created: 2026-09-11 by
Sublime Text allows you to indent or outdent multiple lines simultaneously by using the Tab and Shift+Tab keys while maintaining active cursors. This feature streamlines code formatting by applying consistent indentation levels across all selected regions, ensuring that your syntax remains clean and readable without manual adjustment of each line.

Understanding Multiple Selections

The foundation of efficient multi-line editing in Sublime Text is the ability to have multiple cursors active at once. You can create these selections through various methods, such as holding Ctrl (or Cmd on macOS) and clicking different locations, or using the Ctrl+D shortcut to select the next occurrence of the current word. Once multiple cursors are established, any text editor command you execute will apply to every cursor position simultaneously.

This capability extends beyond simple text selection. When you have multiple vertical cursors aligned on different lines, pressing Tab indents all those lines equally, pushing them further to the right. Conversely, pressing Shift+Tab outdents them, moving them back toward the left margin. This behavior is particularly useful when refactoring code blocks, aligning function arguments, or adjusting nested structures where uniform spacing is required.

Basic Indentation with Multiple Cursors

To demonstrate this workflow, consider a scenario where you have three separate lines of code that need to be grouped under a single parent block. First, ensure you have cursors on each of these lines. You can achieve this by selecting the first line, then holding Alt and clicking at the start of the second and third lines to add additional cursors.

  1. Select the target lines: Place your primary cursor on the first line you wish to modify. Hold Alt (Windows/Linux) or Option (macOS) and click at the desired column position on subsequent lines. This creates vertical cursors.
  2. Apply indentation: Press the Tab key. All lines with active cursors will shift right by one indentation unit (typically two or four spaces, depending on your user settings).
  3. Reverse if necessary: If you have indented too far, press Shift+Tab. This removes one level of indentation from all selected lines simultaneously.

This process ensures that the relative indentation between lines is preserved while changing their absolute position within the document structure. It eliminates the error-prone process of manually hitting the space bar or tab key for each individual line.

Adjusting Indent Settings

The width of a single indentation step is determined by your project or global preferences. By default, Sublime Text often uses four spaces for Python files and two spaces for JavaScript or HTML, but this varies based on the file type and user configuration. To verify or change this setting, navigate to Preferences > Settings.

In the settings file, look for the tab_size property. If it is not present, you can add it to set the number of spaces that represent one tab character. For example, adding "tab_size": 4 will make the Tab key insert four spaces instead of two. Additionally, ensure that "translate_tabs_to_spaces" is set to true if you prefer spaces over literal tab characters for consistent cross-platform rendering.

When working with multiple selections, understanding these underlying settings is crucial because an incorrect tab_size can lead to misaligned code blocks that are difficult to read. Consistent indentation settings across your team or projects help maintain code quality standards.

Advanced Multi-Column Editing Tips

Beyond basic indentation, multiple selections enable powerful editing patterns. For instance, you can use Ctrl+Shift+L to split the current selection into individual lines, placing a cursor at the end of each line. From there, you can move all cursors up or down to adjust indentation levels dynamically.

Another useful technique involves using regular expressions with multiple selections, though this requires caution. While Sublime Text does not support regex directly in the multi-cursor interface, you can combine it with find-and-replace operations after establishing your cursors. However, for pure structural changes like indentation, the keyboard shortcuts remain the most reliable method.

If you frequently work with deeply nested code, consider installing packages that enhance multi-cursor functionality. Packages like SideBarEnhancements or Emmet can integrate with your existing workflow, but native multi-selection remains the core tool for quick structural adjustments. For related tasks, such as running scripts or managing file formats, you might also explore Running VBScripts in Sublime Text to extend your editor's capabilities beyond standard text manipulation.

Common Pitfalls and Solutions

A common issue arises when users attempt to indent mixed selections—some lines already indented, others not. The result may appear uneven if the base indentation levels differ significantly. Always check the visual alignment after applying Tab or Shift+Tab to ensure the logical structure of your code has not been corrupted.

Another pitfall is accidentally creating horizontal selections instead of vertical cursors. If you drag your mouse across multiple lines, you create a block selection, which behaves differently during indentation. Block selections indent the entire block uniformly, whereas vertical cursors allow for more granular control. Use Alt+Click to switch between these modes effectively.

Frequently Asked Questions

How do I select multiple non-contiguous lines?

You can select multiple non-contiguous lines by holding Ctrl (or Cmd) and clicking at the beginning of each line you wish to edit. Alternatively, hold Alt (or Option) and click to place vertical cursors at specific column positions across different lines, allowing for precise multi-column editing.

Why is my indentation inconsistent after using multiple selections?

Inconsistency usually occurs because the lines had different base indentation levels before you applied the command. Since Tab adds a fixed amount of whitespace to each cursor, lines starting further left will still end up further left than those starting closer to the margin. Ensure all target lines have similar initial spacing before adjusting.

Can I undo multiple indentation actions at once?

Yes, pressing Ctrl+Z (or Cmd+Z on macOS) will undo the last action performed on all cursors simultaneously. Each undo step reverses one application of Tab or Shift+Tab, so you may need to press it multiple times if you indented several levels.

Does this feature work with comments and strings?

Yes, multiple selection indentation applies to all text types, including comments and string literals. If you have cursors inside comment blocks or within quoted strings, pressing Tab will indent those specific segments along with the rest of the line, maintaining the overall structure of the code.

How do I remove trailing whitespace from multiple selections?

While multi-selection handles indentation, removing trailing whitespace is best done via the command palette. Press Ctrl+Shift+P, type "Remove Trailing Whitespace," and execute the command. This operation cleans up all lines in the file, complementing your manual indentation efforts.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More