This will replace \n
with an actual newline:
import sublime, sublime_plugin
class TestCommand ( sublime_plugin.TextCommand ):
def run ( self, edit ):
view = self.view
query = "\\n" # backslash is escaped to send a literal backslash
newLine = "\n"
queryRegions = view.find_all ( query, sublime.LITERAL ) # literal flag is used to disable regex
for region in reversed ( queryRegions ): # use reverse region order to avoid displacing regions with previous replacements
view.replace ( edit, region, newLine )
As far as having it happen automatically when opening a .json file, you’d probably have to:
- set up an Event Listener
- use:
window.extract_variables () ["file_extension"]