Chapter 11. Final Time-Savers
I’ve had a lot of fun writing this book, and I hope you’ve had fun reading it too. For the last act, let’s cover a bunch of smaller topics that didn’t quite fit into the earlier chapters. These topics have made me a better Linux user, and maybe they’ll help you as well.
Quick Wins
The following time-savers are simple to learn in a few minutes.
Jumping Into Your Editor from less
When you’re viewing a text file with less
and want to edit the file,
don’t exit less
. Just press v
to launch your preferred text
editor. It loads the file and places the cursor right at the spot
you were viewing in less
. Exit the editor and you’re back in
less
at the original location.
For this trick to work best, set the environment variable EDITOR
and/or VISUAL
to an editing command. These environment variables
represent your default Linux text editor that may be launched by
various commands, including less
, lynx
, git
, crontab
, and numerous email programs.
For example, to set emacs
as your default editor, place either of the following lines (or both)
in a shell configuration file and source it:
VISUAL=emacs EDITOR=emacs
If you don’t set these variables, your default editor is whatever
your Linux system sets it to be, which is usually vim
. If you end up
inside of vim
and you don’t know how to use it, don’t panic. Quit
vim
by pressing the Escape key and typing :q!
(a colon, the letter
q, and an exclamation point), then press Enter. To quit emacs
, press Ctrl-X followed by ...
Get Efficient Linux at the Command Line now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.