Sublime text 3 - console - how to open file

I would like to open files for editing from the sublime text 3 console (which appears on ctrl + `)

I tried

open [filename] 

      

but it always gives a syntax error for the last character of the filename. I tried to include the name in quotes.

Also, I would like to know if I can execute shell commands directly from it console

+3


source to share


3 answers


What's the command:

sublime.active_window().open_file("filename.txt")



It's a little ugly, but can probably be written / automated somehow (like having a shortcut).

+3


source


If you really want to open files from the console (much easier to just press Ctrl O), the following command will open a file selection dialog:

window.run_command("prompt_open_file")

      



There is no command to open a specific file from the console.

If you're interested in learning more about the Sublime Python API, take a look here .

+3


source


The console in Sublime Text Editor is a python console.

To execute shell commands, you need to import os and then execute them:

import os
os.system("date")

      

+1


source







All Articles