When does an Emacs user use Vim? To change a server config via ssh.
Ha, haha! Ha! Awesome joke ... it's funny because it's true! It hurts so much :(
I've been an emacs user for a while now. Still don't know all the keyboard shortcuts, text selection still confuses me to no end and I still think the Ctrl+W command to cut is rather unfortunate because I keep clsoing windows in other environments.
But I love Emacs to bits!
The main reason I started using this operating system is that I don't have to think about code indentation. Almost any language I dare use, Emacs knows how to indent code according to community standards. You might need to install something called a major mode for the language, but hey - package management system!
If you haven't tried coding without thinking about indentation before, you really should. It's marvelous, lets you focus on the important stuff.
That said ... I always used vim via ssh. Always. Perhaps a remnant from my times before Emacs, when I thought Vim was the default thing you use when working without a GUI. Yes, I'm not a neckbeard, I like my GUI and non-tiling window managers to write code.
Enter tramp-mode
Over the past few weeks I've been working on a project that frowns upon the idea of working locally - something about data security when dealing with banking-like systems. Whatever.
The only access to my code was the humble ssh. Now fucking what?
Running emacs via ssh -X was painfully slow. Using Vim for more than config editing? Surely, you're joking [mr. Feynman]!?
After a week of miserably living my life via ssh -X I finally broke down and googled for a solution. Took me long enough ... My surprisingly short search (took me all of 10 minutes) discovered something called tramp-mode - a remote-editing mode for emacs.
Since emacs22 it comes bundled with the basic install, so there's no need to add anything.
It. Is. Amazing.
C-x C-f // and away we go. Enter username@ (lovingly autocompleted by the file finder thingy), add the hostname (also autocompleted). Asks for the password and voila, I'm browsing a remote computer via ssh.
From what I understand, tramp-mode doesn't actually keep you connected via ssh for live editing on the remote machine. That would be slow, a TCP round-about for every keystroke ... no good. Instead it uses scp to copy files locally, let you edit them and when you save the file is copied back into its original location.
For added awesomeness, C-x C-f undestands you're editing remotely so it always starts finding files relative to the remote location.
Magic. All the flexibility of editing locally, all the whatever-you-need-this-for of secure remote connections.
...
But I will still edit configs with Vim. It's only natural.
Continue reading about Cool thing Thursday: Emacs tramp-mode
Semantically similar articles hand-picked by GPT-4
- After a week I must begrudgingly admit VSCode is a better editor than Emacs
- Why I won't be switching to VSCode any time soon
- WebPutty will make your CSS cry virgin unicorn tears of awesome
- WebDAV, girlfriends and linux
- Cool thing Thursday: Contribute to opensource without leaving your browser
Learned something new?
Read more Software Engineering Lessons from Production
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Software Engineering Lessons from Production
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️