Rapidly invoke an editor to write a long, complex, or tricky command

ctrl-x e
Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.
Sample Output
GNU nano 2.0.7         File: /tmp/bash-fc-30782221326                         

# begin writing some exceedingly long and complex command in the editor...

538
By: fool
2009-03-11 09:26:05

4 Alternatives + Submit Alt

What Others Think

use 9term/plan9, pressing escape puts the term in hold mode and nothing is sent until youpress escape again to release it.
maht · 653 weeks and 3 days ago
Nice. You have my vote on this one. This really is gonna be useful. I would write it 'ctrl-x ctrl-e' tho. First reflex to me was to hit 'ctrl-x' release it and then press 'e' (i'm used to screen like shortcuts)
skinp · 653 weeks and 3 days ago
Also forgot to say, this is REALLY going to be useful when entering a long command, test it and then want to make a script out of it. no need to 'echo !! > script'. Just command history up, ctrl-x ctrl-e, and save :D
skinp · 653 weeks and 3 days ago
or just type fc and hit the enter key
linuxrawkstar · 653 weeks and 2 days ago
Didn't work for me. This is presumably as I use vi mode.
krayon · 653 weeks and 2 days ago
In vi mode, it's esc (for command mode) and then v.
jstrater · 651 weeks and 6 days ago
You have to configure the VISUAL enviromnet variable prior to use C-x, C-e export VISUAL=vi
vutcovici · 650 weeks and 2 days ago
It's C-x C-e.
kylexlau · 644 weeks and 2 days ago
Doesn't work in zsh.
eolo999 · 637 weeks ago
note: When you save this with its given filename (just :wq), it is executed and then discarded by the shell. If you want to keep it, save it explicitly to a new file first (:w )
cj_ · 616 weeks and 6 days ago
Oops, that should read :w <newfile>
cj_ · 616 weeks and 6 days ago
To enable this on zsh, add autoload edit-command-line zle -N edit-command-line bindkey '^Xe' edit-command-line to your .zshrc
Erus · 601 weeks and 2 days ago
I agree with linuxrawkstar. fc is simpler, and it's much more flexible.
chrispix · 598 weeks and 5 days ago
Thanks Erus.
dserodio · 519 weeks and 2 days ago
How do you set the editor to say sublime? I assume it would go in the .bash_profile file.
cmbowyer13 · 114 weeks and 6 days ago
Love this website for guiding people. download pokemon emerald rom
JackHenry8899 · 36 weeks and 5 days ago
Gotoassignmenthelp is team of leading professional writers for Essays Help Online Writing Services to students all around the world. Contact us today for Best maths assignment at very affordable price. Under GotoAssignmentHelp we provide many types of help to the students. We are the most reliable assignment helpers. We have gained our specialization after spending most of our times in making ourselves perfect. We providing 100% plagiarism free Assignment Help. At the point when you pick our java help assistance, our faculty will consider the quality and your evaluation criteria.
annybank2018 · 16 weeks and 5 days ago
Toto Site Sports Toto Safety Playground Boatman Slot Site Overseas Soccer Sports Relay Reserve Army Schedule Naroho Space Center Celebrity Tax Evasion Viral Marketing Corona Vaccination Toto Site Address Casino Coupon Private Toto Subscription Play Tech Sports Highest Dividendhttps://bebe40.com https://sports-totosite.com https://ubi40.com https://linktr.ee/totosite365
totosite40 · 10 weeks and 4 days ago
Assignments are completed throughout your time in university and are used by tutors to measure your progress and understanding of a course or module. Our University assignment help UK will create a 100% cheap assignment writing service uk that will help you to be the best. We work with a professional team of UK based Online assignment maker who, following your requirements and instructions, will develop a model answer which is flawlessly structured, well-sourced and written in perfect English.
david230 · 6 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: