Tuesday, January 14, 2025

Sublime Text - Remove whitespace at start of a line

 Really similar blog post to a previous one I made on removing trailing white space. 

Much like that use case, I also use this frequently when drafting configuration changes for Cisco and other network devices. I've run into weird edge cases in the past where start of line white spaces result in line wraps or out of order commands when copy and pasting, or using something like netmiko's .send_config_from_file function to push a blob of configuration to a device


In sublime text

Ctrl+H to bring up the find/replace 

Alt+R to enable regex

in the find box, copy ^\s+  make sure the s is lower case!

Keep the replace box empty

At your discretion, select Replace or Replace All to remove start of line whitespaces. 

Its worth noting, this will also remove newlines, condensing your text. Machines like this, but humans tend not to as its not really pretty to look at. 


Before:

 

 

After:

 

No comments:

Post a Comment

Using Powershell to prep for a DHCP cutover

 Alright, here is the background.  Recently I was working on migrating a few locations off of bog standard Microsoft Windows DHCP server to ...