Lo-Fi Python

Aug 07, 2023

Opening Files From The Terminal With Text Editor CLIs

Most text editors can open files from a computer's command line shell. Here are 8 different text editor commands for opening a file:

IDLE (Python's Built-in Editor)

idle file.py
CLI help options for Python's IDLE text editor

image source: IDLE documentation

Sublime

subl template.rst
using subl CLI to open files in Sublime

VS Code

code file.py

Atom

atom file.py

Emacs

emacs -nw file.txt

source: Stack Overflow user Anthon

Notepad++

start notepad++ file.py

source: W3 Schools

TextEdit

open -a TextEdit file.txt

source: Stack Overflow user robmathers

Vim

:e file.txt

source: confirm blog

The ability to quickly pop open and view a file is essential. Ubuntu has the cat command to print a file's contents to the terminal screen also if you don't need to edit it. Tools like sed and awk are useful for command line file editing if you prefer to keep it in the terminal.

Want to read more about text editors? Check out my text editor file size comparison here.