Sublime Forum

How can enforce 2 spaces on any line NOT starting with a [

#1

All,

First hour using Sublime here. Looks cool. What brought me here is the Splunk plug in. The plug in is great but one minor tweak. We need to have every line of configuration that does not start with a open bracket “[” spaces 2 times by our company standard.

So basically
#don’t want
[script://.\bin\winfim.exe scan]
index=compliance
sourcetype=winfim
interval = 240

# want
[script://.\bin\winfim.exe init]
  index=compliance
  sourcetype=winfim 
  interval = 120

Any idea how I could do this?

0 Likes

#2

You can set tab size to 2, then find&replace with regex:

find field: ^([^\[])
replace field: \t\1

and do replace all

2 Likes

#3

Ah, thats a cool feature. But I was more looking for the UI to do this for me every time I new line.

0 Likes

#4

Try this:

  • download https://packagecontrol.io/packages/Splunk%20Syntax

  • assign Splunk syntax to the file

  • open syntax preferences for splunk syntax(Preferences->Settings - Syntax Specific), and paste:

     "tab_size": 2,
    
  • create a file named splunk.tmPreferences in User folder and paste this:


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>name</key>
       <string>Splunk Metadata</string>
       <key>scope</key>
       <string>source.splunk</string>
       <key>settings</key>
       <dict>
          <key>increaseIndentPattern</key>
          <string>^.*\]$</string>
       </dict>
       <key>uuid</key>
       <string>A80A9499-C886-4104-B64F-61F258900092</string>
    </dict>
    </plist>
0 Likes