Sublime Forum

Reformat/Reindent Code (Plain Text)

#1

Hi there,

is there a way to reformat/reindent code of a plain text file, unsaved or saved?

I am working with a proprietary script language not supported or listed here. I deciced to move from notepad++ using TextFX-Plugin which allowed me to reformat code indepentendly from the coding language (not definied).

I tried several packages but all require to define a language which I don’t want/need because sometimes I just have some code which I want to manipulate, reformat and forget.

best regards

example code

if((push_service == "alle") || (push_service == "Pushover")){ ! Informationsmeldungen "HomeMatic" if((prio == -2) || (prio == -1) || (prio == 0)){ ! User1 dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("extra/curl -s -k -d token='"#HMinfo1_pushover#"' -d user='"#key1_pushover#"' -d message='"#message#"' -d priority='"#prio#"' -d sound='"#sound#"' -d html=1 https://api.pushover.net/1/messages.json"); ! User2 nur, wenn prio >= prio_min_pushover if(key2_pushover != " "){ if(prio >= prio_min_pushover){ dom.GetObject("CUxD.CUX2801001:1.CMD_EXEC").State("extra/curl -s -k -d token='"#HMinfo2_pushover#"' -d user='"#key2_pushover#"' -d message='"#message#"' -d priority='"#prio#"' -d sound='"#sound#"' -d html=1 https://api.pushover.net/1/messages.json"); } } } }

0 Likes

#2

looks quite like C, and intending as such works. I did:

  • CTRLSHIFTP to open Command palette

  • S S C Enter selected C as current syntax

  • CTRLA to select all code

  • CTRLSHIFTP to open Command palette again

  • r e i n Enter to issue the reindent command

0 Likes

#3

Thank you for the advice! Unfortunately, thats not the “easy” solution I was hoping for… But it’s something, atleast as long as I dont forget to set the syntax (and I open/close tabs alot… hmpf :frowning: )

Can I guess there is no package which allows reindent of “plain text” even if there are brackets and stuff?

0 Likes

#4

well, you could alter the Plain Text syntax to provide neccesary indent hints to sublime but imho record a macro and assigning it to a shortcut is easier.

also check this https://forum.sublimetext.com/t/how-to-set-default-syntax-on-new-window-tab/

0 Likes