Sublime Forum

Switch lines and accomodate commas?

#1

So there’s this shortcut “Shitf + Ctrl + Up/Down”, that will move the line you are on at the moment right?

for example:

var someObject = {
att1: ‘att1’,
att2: ‘att2’,
att3: ‘att3’
}

I wanted to know if it would be possible to make ST switch lines att2 and att3 but fix the comma at the end so this doesn’t end up like:

var someObject = {
att1: ‘att1’,
** att3: ‘att3’**
att2: ‘att2’,
}

Is this already there? is there a plugin/addon for this?

Thanks!

0 Likes

#2

This is a great idea! I might work on something like this if nothing pops up by the time I wrap up the handful of plugins I’m working on now.

I’d love to be able to switch from

for ( String string_X : stringList )
	{
		if ( condition == True )
			{
				doSomething = True;
				newString   = "";
			}
		else if ( condition == False )
			{
				doSomething = False;
				newString   = string_X;
			}
	}

to

for ( String string_X : stringList ) {
	if ( condition == True ) {
		doSomething = True;
		newString   = ""; }
		
	else if ( condition == False ) {
		doSomething = False;
		newString   = string_X; }
}

Much easier to read, & it would save me sooooo many lines lol :joy:. Seriously though… :weary:.
I’d make the switch if it wasn’t such a hassle to maintain.

1 Like