When typing a very long command, I'd like to first edit the command in a text editor(e.g. vi) then execute in case of typos. Is there a way to edit the command directly in a terminal and run instead of invoke vi by typing vi then type the command?
Press the Insert or I key on your keyboard, and then move the cursor to the location where you want to edit. 4. Modify the file based on your needs, and then press the Esc key to exit the input mode.
The default editor that comes with the UNIX operating system is called vi (visual editor). Using vi editor, we can edit an existing file or create a new file from scratch. we can also use this editor to just read a text file. Syntax: vi filename.
If you're using bash, try the edit-and-execute-command
command. By default, this is assigned to Ctrl-x Ctrl-e
(type ctrl-x, then ctrl-e).
This should open whatever editor is specified in your environment. Whatever is in the buffer when you exit will execute in the shell - including multiple-line commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With