How to open a .py file in sublime from a terminal console?

  • Python
  • Thread starter member 428835
  • Start date
  • Tags
    File
In summary, the conversation discusses different ways to open the file hello.py in the sublime text editor from the terminal. The options include using "subl hello.py" or "open -a /Applications/MyFavoriteTextEditor.app hello.py". The conversation also mentions creating an alias for the latter option.
  • #1
member 428835
Hi PF!

To open hello.py in the past I've used gedit hello.py but this opens the file in text editor. I would prefer to use sublime since it has features that are appealing to me. So my question is, how do I open hello.py in sublime from the terminal?
 
Technology news on Phys.org
  • #2
sublime hello.py doesn't work?
 
  • Like
Likes member 428835 and phyzguy
  • #3
PeterDonis said:
sublime hello.py doesn't work?
Didn't realize it was this simple; thanks! (it's actually subl hello.py, but thanks)
 
  • #4
joshmccraney said:
Didn't realize it was this simple

On Unix-type systems it's a pretty general pattern that <program-name> <filename> at the shell opens the program operating on that file. Of course you still get curve balls like the program name being "subl" instead of "sublime". :wink:
 
  • Like
Likes member 428835
  • #5
Got it! Fortunately tab kinda takes care of this :)
 
  • #6
On mac machine you can say:
Bash:
$$ open <filename>
and it will select the proper editor or viewer or to be selective:
Bash:
$$ open -a /Applications/MyFavoriteTextEditor.app <filename>
where MyfavoriteTextEditor is a subfolder in the /Applications folder.

I even added an alias like:
Bash:
$$ alias ted=open -a /Applications/MyFavoriteTextEditor.app <filename>

$$ ted <filename>
 

FAQ: How to open a .py file in sublime from a terminal console?

1. How do I open a .py file in Sublime from a terminal console?

To open a .py file in Sublime from a terminal console, you can use the command "subl ". This will open the file in a new tab in Sublime.

2. Can I edit the .py file in Sublime from the terminal console?

Yes, you can edit the .py file in Sublime from the terminal console. After opening the file in Sublime, any changes you make will be reflected in the file on your computer.

3. How can I navigate to a specific line in the .py file using the terminal console?

To navigate to a specific line in the .py file, you can use the command "subl :". This will open the file in Sublime and take you directly to the specified line number.

4. Is it possible to open multiple .py files in Sublime from the terminal console?

Yes, it is possible to open multiple .py files in Sublime from the terminal console. You can use the command "subl " to open multiple files in separate tabs in Sublime.

5. Can I customize the settings for opening .py files in Sublime from the terminal console?

Yes, you can customize the settings for opening .py files in Sublime from the terminal console. You can add aliases or shortcuts in your terminal configuration file to make the process more efficient.

Similar threads

Replies
10
Views
2K
Replies
9
Views
3K
Replies
12
Views
8K
Replies
16
Views
3K
Replies
18
Views
1K
Back
Top