Shell-based text editors
You know what I love about data science? Most of the time, I get to work in comfortable environments with VSCode, Jupyter notebooks, and all the graphical tools I want. But then reality hits: I need to SSH into a remote server, or I'm working in a Docker container, or I just need to quickly fix a config file, and suddenly I'm staring at a terminal with no GUI in sight.
This is where knowing at least one shell-based text editor becomes essential. Trust me, you don't want to be that person who downloads a file, edits it locally, and uploads it back just to change one line in a configuration file.
For keeping your editor settings consistent across machines, see using dotfiles for environment management. This ensures your nano configuration and other editor preferences are portable.
For creating aliases that make your editor more accessible, see how to create shell command aliases. Aliases can simplify common editing tasks and make your workflow more efficient.
Why should I care about shell editors?
Here's the thing: as a data scientist, you'll inevitably find yourself in situations where you need to edit files but don't have access to your favorite graphical editor. This happens more often than you'd think:
- SSH sessions: Working on remote servers where only terminal access is available
- Docker containers: Quick fixes inside containerized environments
- Cloud instances: Editing configuration files on cloud machines
- Git workflows: Editing commit messages or resolving merge conflicts
- Emergency fixes: When something breaks and you need to fix it fast
Shell-based editors are your lifeline in these situations because they're:
- Always available on Unix-like systems (which is basically every server you'll encounter)
- Lightweight and fast - they load instantly, even on slow connections
- Perfect for quick edits - no need to open heavy IDEs for simple changes
What do I actually need to learn?
Don't overthink this. The goal isn't to become a shell editor power user - it's to be competent enough to make quick edits without frustration. You need to master exactly three things:
- Open a file - Start editing
- Navigate and edit - Move around and make changes
- Save and exit - Preserve your work and get out
Master these three actions in any text editor and you'll be productive. Everything else is nice-to-have.
My recommendation: start with nano
I'm going to save you some pain here. While vim and emacs are incredibly powerful, they have steep learning curves that can be frustrating when you just want to edit a config file. I recommend starting with nano
because:
- It's approachable - no mysterious modes or complex key combinations
- Help is visible - commands are shown at the bottom of the screen
- It's widely available - installed on most systems by default
- It just works - you can be productive immediately
Getting started with nano
Opening a file is dead simple:
nano filename.txt # Opens the file for editing
The commands you need are shown right at the bottom of the screen, but here are the essentials:
Ctrl+X
- Exit nano (it'll ask if you want to save)Ctrl+O
- Save file (WriteOut)Ctrl+W
- Search in fileCtrl+K
- Cut entire lineCtrl+U
- Paste lineCtrl+G
- Show full help
That's it. You're now capable of editing files in a terminal. Everything else is optional.
Making nano more pleasant to use
Nano's default appearance is pretty bare-bones, but you can improve it significantly with minimal effort. The biggest upgrade is adding syntax highlighting, which makes code much more readable.
The easy way: nanorc
Anthony Scopatz maintains nanorc, a collection of syntax highlighting configurations for nano. Installing it is a one-liner:
curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | sh
This instantly gives you syntax highlighting for:
- Python (
.py
) - JavaScript (
.js
) - JSON (
.json
) - YAML (
.yaml
,.yml
) - Markdown (
.md
) - Shell scripts (
.sh
) - And many more file types
The difference is night and day - your code will suddenly have colors and structure that make it much easier to read.
If you want more control
You can also set up nano manually and customize it to your liking:
# Create nano config directory
mkdir -p ~/.nano
# Download syntax files
git clone https://github.com/scopatz/nanorc.git ~/.nano/nanorc
# Add to your nano config
echo "include ~/.nano/nanorc/*.nanorc" >> ~/.nanorc
My nano configuration
Here's the ~/.nanorc
configuration I use. Feel free to copy it:
# Enable syntax highlighting from the nanorc collection
include ~/.nano/nanorc/*.nanorc
# Show line numbers (helpful for debugging)
set linenumbers
# Enable mouse support (yes, this works in most terminals!)
set mouse
# Set tab size to 4 spaces
set tabsize 4
# Enable auto-indentation
set autoindent
# Show whitespace characters (helps catch trailing spaces)
set whitespace
# Enable soft wrapping of long lines
set softwrap
These settings make nano much more pleasant to use while keeping it simple.
What about vim and emacs?
Look, vim and emacs are incredibly powerful editors with devoted followings. If you want to invest the time to learn them, they can become extensions of your thinking. But here's my honest take: unless you're going to use them regularly, the learning curve isn't worth it for most data scientists.
That said, you should know the absolute basics of vim because it's the default editor for many system operations (like Git commit messages):
Vim survival guide
If you accidentally open vim (it happens), here's how to escape:
- To exit: Press
Esc
, then type:q!
and hit Enter (quits without saving) - To save and exit: Press
Esc
, then type:wq
and hit Enter
If you want to actually edit something:
- Insert mode: Press
i
to start typing - Back to command mode: Press
Esc
- Save and exit shortcut:
Shift+ZZ
Emacs basics
If you encounter emacs:
- Exit:
Ctrl+X, Ctrl+C
- Save:
Ctrl+X, Ctrl+S
My philosophy on shell editors
Here's what I've learned after years of working in terminals: mastery of one editor beats mediocrity in several. Pick nano (or vim if you're feeling ambitious), learn it well enough to be comfortable, and move on.
The goal isn't to become a terminal text editing wizard - it's to be competent enough that editing files in SSH sessions doesn't slow you down. Save your energy for learning the data science tools that actually matter to your work.
Getting started
Here's how I recommend approaching this:
- Install nanorc - Run that one-liner above to get syntax highlighting
- Practice on a throwaway file - Create a test file and just get comfortable with the basic operations
- Use it for real - Next time you need to edit a config file or fix something on a server, use nano instead of downloading/uploading files
Remember: the best shell editor is the one you'll actually use when you need it. For most data scientists, that's nano.