Advantages of using set -o vi
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
bash vim vi
add a comment |
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
bash vim vi
add a comment |
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
bash vim vi
I have seen many developers using this command to set the option to vi. I never understood the real use of this?
When using bash commands, what help does switching to vi provide?
bash vim vi
bash vim vi
edited May 14 '14 at 14:10
Braiam
23.1k1976137
23.1k1976137
asked Jan 31 '12 at 6:43
Chander Shivdasani
5343711
5343711
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
By setting your readline editing to either emacs (the default) or vi (set -o vi
) you are essentially standardizing your editing commands, across the shell and your editor of choice1.
Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command syntax and (if that were not advantage enough) would probably make your editing in both environments faster and less error prone...
You can further leverage this relationship in vi-mode by pulling up any command from your shell history, hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command loaded for more complex editing with the full power of vim. Once you have finished editing the command to your satisfaction, :wq and the command is executed back in your shell.
1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
The Esc-v trick is one of the best features ofset -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).
– Michael Goldshteyn
May 1 at 19:31
1
The Esc-v trick is not really an advantage specific toset -o vi
. Under the default setting ofset -o EMACS
, C-x,C-e will bring up an emacs window (or the$EDITOR
, if set) in which you can edit the command before running it.
– John Gowers
Jul 31 at 17:43
add a comment |
Vi mode is a huge usability improvement if you are using a mobile SSH client like ConnectBot for Android.
This is due to a reduced reliance on modifier keys.
Vim is much easier to use with a virtual keyboard on a smartphone or tablet than ... anything else, including the native editing methods built into the Android UI. Ironically, it is easier to edit C sources with Vim in an SSH session than to edit, say, an instant message with the platform's own editing widget for that purpose.
Shell vi mode brings a similar benefit.
add a comment |
I'm not sure if there is a direct advantage. I've been a vi
user for more than 20 years. I'm also a screen
user for even longer, and of other programs that use vi
keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers whenssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my.bashrc
stuff on it.
– Kyle Strand
Jan 5 '16 at 20:48
add a comment |
It lets you edit stuff at the command line using the vi modes and operations.
An example will help make it much clearer:
You type cp tmp/some_other_long_directory/file1.xt /tmp2/some_other_xtra_long_dir/
but you get an error - you should have typed file1.txt
not file1.xt
Without this option set, you press up-arrow and then press left arrow and let it repeat for... 35 times, until you get to the .xt
and then you type the extra t
. Total keystrokes: 37.
With this option set you can (for example) press arrow up once, then Escape for command mode, 0 to go to the start of the line and then /xt[return]
to get to the xt
and then you can type i
for insert mode and type the missing t. This may seems insanely complicated in some respects but if you are a vim user these command are already very well known. Total keystrokes: 9
1
You could use a fewAlt+B
s or aCtrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.
– Mikel
Apr 1 '14 at 0:11
2
Seeing as we're golfing: Emacs mode:Up
,Ctrl+Alt+]
,.
,Right
,t
,Enter
= 8. Vi mode:Up
,F
,.
,a
,t
,Enter
= 7. :)
– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you haveEsc
in there too, it's a dead heat.
– dragon788
Oct 15 '17 at 5:44
add a comment |
The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.
NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline
, like bash
.
add a comment |
If you get used to vi
, so you set it to vi mode as your shell editor. That'd be the obvious reason. The other one is when the bash
is not available by default in some OSes (mostly UNIX like AIX, Solaris), so the shell history feature is not available, so the way you get the past commands by setting the shell editor to vi
, and Esc, Ctrl+K or Ctrl+L
add a comment |
It can let you easily navigate and edit the command line using vim's shortcuts, e.g. quickly move to one word right, delete a word.
By the default shortcuts, when you need to go to the end of the line, you need to Ctrl+e, whereas with set -o vi
, you just hit $
, like in vim.
add a comment |
Probably late to the party, but for me using the vi mode is more about when creating interactive scrips.. for example
for i in `ls | grep -v gz`
do
echo $i
gzip $i
done
a very simple example of what could be quite complicated.. using ESCkv puts you into a vi session where you can modify the script, and then :wq
and it runs.
1
This may be a good example of using bash invi
mode, but it's a bad example of bash code. (1) Using the output fromls
as the input to any other sort of processing is a bad idea. (2) The$(…)
syntax for command substitution is widely considered to be more readable than the`…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.
– G-Man
Sep 5 '15 at 18:13
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f30454%2fadvantages-of-using-set-o-vi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
By setting your readline editing to either emacs (the default) or vi (set -o vi
) you are essentially standardizing your editing commands, across the shell and your editor of choice1.
Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command syntax and (if that were not advantage enough) would probably make your editing in both environments faster and less error prone...
You can further leverage this relationship in vi-mode by pulling up any command from your shell history, hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command loaded for more complex editing with the full power of vim. Once you have finished editing the command to your satisfaction, :wq and the command is executed back in your shell.
1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
The Esc-v trick is one of the best features ofset -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).
– Michael Goldshteyn
May 1 at 19:31
1
The Esc-v trick is not really an advantage specific toset -o vi
. Under the default setting ofset -o EMACS
, C-x,C-e will bring up an emacs window (or the$EDITOR
, if set) in which you can edit the command before running it.
– John Gowers
Jul 31 at 17:43
add a comment |
By setting your readline editing to either emacs (the default) or vi (set -o vi
) you are essentially standardizing your editing commands, across the shell and your editor of choice1.
Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command syntax and (if that were not advantage enough) would probably make your editing in both environments faster and less error prone...
You can further leverage this relationship in vi-mode by pulling up any command from your shell history, hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command loaded for more complex editing with the full power of vim. Once you have finished editing the command to your satisfaction, :wq and the command is executed back in your shell.
1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
The Esc-v trick is one of the best features ofset -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).
– Michael Goldshteyn
May 1 at 19:31
1
The Esc-v trick is not really an advantage specific toset -o vi
. Under the default setting ofset -o EMACS
, C-x,C-e will bring up an emacs window (or the$EDITOR
, if set) in which you can edit the command before running it.
– John Gowers
Jul 31 at 17:43
add a comment |
By setting your readline editing to either emacs (the default) or vi (set -o vi
) you are essentially standardizing your editing commands, across the shell and your editor of choice1.
Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command syntax and (if that were not advantage enough) would probably make your editing in both environments faster and less error prone...
You can further leverage this relationship in vi-mode by pulling up any command from your shell history, hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command loaded for more complex editing with the full power of vim. Once you have finished editing the command to your satisfaction, :wq and the command is executed back in your shell.
1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...
By setting your readline editing to either emacs (the default) or vi (set -o vi
) you are essentially standardizing your editing commands, across the shell and your editor of choice1.
Thus, if you want to edit a command in the shell you use the same commands2 that you would if you were in your text editor. This means only having to remember one command syntax and (if that were not advantage enough) would probably make your editing in both environments faster and less error prone...
You can further leverage this relationship in vi-mode by pulling up any command from your shell history, hitting Escape to enter command mode and then hitting v, which will open your $EDITOR with the command loaded for more complex editing with the full power of vim. Once you have finished editing the command to your satisfaction, :wq and the command is executed back in your shell.
1. Assuming, of course, that you use Emacs or Vi/m as your editor.
2. Or, more accurately, a subset thereof...
edited Oct 30 '13 at 3:12
answered Jan 31 '12 at 7:02
jasonwryan
49.2k14134184
49.2k14134184
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
The Esc-v trick is one of the best features ofset -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).
– Michael Goldshteyn
May 1 at 19:31
1
The Esc-v trick is not really an advantage specific toset -o vi
. Under the default setting ofset -o EMACS
, C-x,C-e will bring up an emacs window (or the$EDITOR
, if set) in which you can edit the command before running it.
– John Gowers
Jul 31 at 17:43
add a comment |
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
The Esc-v trick is one of the best features ofset -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).
– Michael Goldshteyn
May 1 at 19:31
1
The Esc-v trick is not really an advantage specific toset -o vi
. Under the default setting ofset -o EMACS
, C-x,C-e will bring up an emacs window (or the$EDITOR
, if set) in which you can edit the command before running it.
– John Gowers
Jul 31 at 17:43
1
1
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
I got the holy grail :)....
– Sathyam
Jan 20 '17 at 12:44
2
2
The Esc-v trick is one of the best features of
set -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).– Michael Goldshteyn
May 1 at 19:31
The Esc-v trick is one of the best features of
set -o vi
that most people don't know. This is especially true if you want to issue the same command multiple times with different arguments (as multiple command line commands).– Michael Goldshteyn
May 1 at 19:31
1
1
The Esc-v trick is not really an advantage specific to
set -o vi
. Under the default setting of set -o EMACS
, C-x,C-e will bring up an emacs window (or the $EDITOR
, if set) in which you can edit the command before running it.– John Gowers
Jul 31 at 17:43
The Esc-v trick is not really an advantage specific to
set -o vi
. Under the default setting of set -o EMACS
, C-x,C-e will bring up an emacs window (or the $EDITOR
, if set) in which you can edit the command before running it.– John Gowers
Jul 31 at 17:43
add a comment |
Vi mode is a huge usability improvement if you are using a mobile SSH client like ConnectBot for Android.
This is due to a reduced reliance on modifier keys.
Vim is much easier to use with a virtual keyboard on a smartphone or tablet than ... anything else, including the native editing methods built into the Android UI. Ironically, it is easier to edit C sources with Vim in an SSH session than to edit, say, an instant message with the platform's own editing widget for that purpose.
Shell vi mode brings a similar benefit.
add a comment |
Vi mode is a huge usability improvement if you are using a mobile SSH client like ConnectBot for Android.
This is due to a reduced reliance on modifier keys.
Vim is much easier to use with a virtual keyboard on a smartphone or tablet than ... anything else, including the native editing methods built into the Android UI. Ironically, it is easier to edit C sources with Vim in an SSH session than to edit, say, an instant message with the platform's own editing widget for that purpose.
Shell vi mode brings a similar benefit.
add a comment |
Vi mode is a huge usability improvement if you are using a mobile SSH client like ConnectBot for Android.
This is due to a reduced reliance on modifier keys.
Vim is much easier to use with a virtual keyboard on a smartphone or tablet than ... anything else, including the native editing methods built into the Android UI. Ironically, it is easier to edit C sources with Vim in an SSH session than to edit, say, an instant message with the platform's own editing widget for that purpose.
Shell vi mode brings a similar benefit.
Vi mode is a huge usability improvement if you are using a mobile SSH client like ConnectBot for Android.
This is due to a reduced reliance on modifier keys.
Vim is much easier to use with a virtual keyboard on a smartphone or tablet than ... anything else, including the native editing methods built into the Android UI. Ironically, it is easier to edit C sources with Vim in an SSH session than to edit, say, an instant message with the platform's own editing widget for that purpose.
Shell vi mode brings a similar benefit.
edited Dec 18 at 16:39
answered Nov 28 '13 at 0:15
Kaz
4,57811432
4,57811432
add a comment |
add a comment |
I'm not sure if there is a direct advantage. I've been a vi
user for more than 20 years. I'm also a screen
user for even longer, and of other programs that use vi
keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers whenssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my.bashrc
stuff on it.
– Kyle Strand
Jan 5 '16 at 20:48
add a comment |
I'm not sure if there is a direct advantage. I've been a vi
user for more than 20 years. I'm also a screen
user for even longer, and of other programs that use vi
keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers whenssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my.bashrc
stuff on it.
– Kyle Strand
Jan 5 '16 at 20:48
add a comment |
I'm not sure if there is a direct advantage. I've been a vi
user for more than 20 years. I'm also a screen
user for even longer, and of other programs that use vi
keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.
I'm not sure if there is a direct advantage. I've been a vi
user for more than 20 years. I'm also a screen
user for even longer, and of other programs that use vi
keys. It's natural for me to prefer to set "vi" mode in bash. But I also work on hundreds of servers in my job, most are set to the default "emacs" mode. So I need to use both modes. But it is really just a matter of preference.
edited Jan 31 '12 at 13:18
Kevin
27k106199
27k106199
answered Jan 31 '12 at 7:18
Arcege
16.9k44157
16.9k44157
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers whenssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my.bashrc
stuff on it.
– Kyle Strand
Jan 5 '16 at 20:48
add a comment |
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers whenssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my.bashrc
stuff on it.
– Kyle Strand
Jan 5 '16 at 20:48
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
Similar situation for me - I use vim a lot but I've always found it less work to become proficient at the default emacs-like readline keys (which can be just as convenient as the vi subset) than it is to add a line switching to the vi mode on every new system I come across.
– jw013
Jan 31 '12 at 20:52
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers when
ssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my .bashrc
stuff on it.– Kyle Strand
Jan 5 '16 at 20:48
I don't work on hundreds of servers, but I do use sshrc to keep my bash setup similar between different computers when
ssh
ing. Of course, that doesn't help when I'm using a machine locally that doesn't have my .bashrc
stuff on it.– Kyle Strand
Jan 5 '16 at 20:48
add a comment |
It lets you edit stuff at the command line using the vi modes and operations.
An example will help make it much clearer:
You type cp tmp/some_other_long_directory/file1.xt /tmp2/some_other_xtra_long_dir/
but you get an error - you should have typed file1.txt
not file1.xt
Without this option set, you press up-arrow and then press left arrow and let it repeat for... 35 times, until you get to the .xt
and then you type the extra t
. Total keystrokes: 37.
With this option set you can (for example) press arrow up once, then Escape for command mode, 0 to go to the start of the line and then /xt[return]
to get to the xt
and then you can type i
for insert mode and type the missing t. This may seems insanely complicated in some respects but if you are a vim user these command are already very well known. Total keystrokes: 9
1
You could use a fewAlt+B
s or aCtrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.
– Mikel
Apr 1 '14 at 0:11
2
Seeing as we're golfing: Emacs mode:Up
,Ctrl+Alt+]
,.
,Right
,t
,Enter
= 8. Vi mode:Up
,F
,.
,a
,t
,Enter
= 7. :)
– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you haveEsc
in there too, it's a dead heat.
– dragon788
Oct 15 '17 at 5:44
add a comment |
It lets you edit stuff at the command line using the vi modes and operations.
An example will help make it much clearer:
You type cp tmp/some_other_long_directory/file1.xt /tmp2/some_other_xtra_long_dir/
but you get an error - you should have typed file1.txt
not file1.xt
Without this option set, you press up-arrow and then press left arrow and let it repeat for... 35 times, until you get to the .xt
and then you type the extra t
. Total keystrokes: 37.
With this option set you can (for example) press arrow up once, then Escape for command mode, 0 to go to the start of the line and then /xt[return]
to get to the xt
and then you can type i
for insert mode and type the missing t. This may seems insanely complicated in some respects but if you are a vim user these command are already very well known. Total keystrokes: 9
1
You could use a fewAlt+B
s or aCtrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.
– Mikel
Apr 1 '14 at 0:11
2
Seeing as we're golfing: Emacs mode:Up
,Ctrl+Alt+]
,.
,Right
,t
,Enter
= 8. Vi mode:Up
,F
,.
,a
,t
,Enter
= 7. :)
– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you haveEsc
in there too, it's a dead heat.
– dragon788
Oct 15 '17 at 5:44
add a comment |
It lets you edit stuff at the command line using the vi modes and operations.
An example will help make it much clearer:
You type cp tmp/some_other_long_directory/file1.xt /tmp2/some_other_xtra_long_dir/
but you get an error - you should have typed file1.txt
not file1.xt
Without this option set, you press up-arrow and then press left arrow and let it repeat for... 35 times, until you get to the .xt
and then you type the extra t
. Total keystrokes: 37.
With this option set you can (for example) press arrow up once, then Escape for command mode, 0 to go to the start of the line and then /xt[return]
to get to the xt
and then you can type i
for insert mode and type the missing t. This may seems insanely complicated in some respects but if you are a vim user these command are already very well known. Total keystrokes: 9
It lets you edit stuff at the command line using the vi modes and operations.
An example will help make it much clearer:
You type cp tmp/some_other_long_directory/file1.xt /tmp2/some_other_xtra_long_dir/
but you get an error - you should have typed file1.txt
not file1.xt
Without this option set, you press up-arrow and then press left arrow and let it repeat for... 35 times, until you get to the .xt
and then you type the extra t
. Total keystrokes: 37.
With this option set you can (for example) press arrow up once, then Escape for command mode, 0 to go to the start of the line and then /xt[return]
to get to the xt
and then you can type i
for insert mode and type the missing t. This may seems insanely complicated in some respects but if you are a vim user these command are already very well known. Total keystrokes: 9
edited Mar 31 '14 at 0:57
answered Nov 28 '13 at 2:44
Michael Durrant
15.7k44113182
15.7k44113182
1
You could use a fewAlt+B
s or aCtrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.
– Mikel
Apr 1 '14 at 0:11
2
Seeing as we're golfing: Emacs mode:Up
,Ctrl+Alt+]
,.
,Right
,t
,Enter
= 8. Vi mode:Up
,F
,.
,a
,t
,Enter
= 7. :)
– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you haveEsc
in there too, it's a dead heat.
– dragon788
Oct 15 '17 at 5:44
add a comment |
1
You could use a fewAlt+B
s or aCtrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.
– Mikel
Apr 1 '14 at 0:11
2
Seeing as we're golfing: Emacs mode:Up
,Ctrl+Alt+]
,.
,Right
,t
,Enter
= 8. Vi mode:Up
,F
,.
,a
,t
,Enter
= 7. :)
– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you haveEsc
in there too, it's a dead heat.
– dragon788
Oct 15 '17 at 5:44
1
1
You could use a few
Alt+B
s or a Ctrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.– Mikel
Apr 1 '14 at 0:11
You could use a few
Alt+B
s or a Ctrl+Alt+]
.
in Emacs mode too, so this doesn't seem like a strong example to me.– Mikel
Apr 1 '14 at 0:11
2
2
Seeing as we're golfing: Emacs mode:
Up
, Ctrl+Alt+]
, .
, Right
, t
, Enter
= 8. Vi mode: Up
, F
, .
, a
, t
, Enter
= 7. :)– Mikel
Apr 1 '14 at 0:44
Seeing as we're golfing: Emacs mode:
Up
, Ctrl+Alt+]
, .
, Right
, t
, Enter
= 8. Vi mode: Up
, F
, .
, a
, t
, Enter
= 7. :)– Mikel
Apr 1 '14 at 0:44
@Mikel you forgot that vi mode starts in Insert mode so you have
Esc
in there too, it's a dead heat.– dragon788
Oct 15 '17 at 5:44
@Mikel you forgot that vi mode starts in Insert mode so you have
Esc
in there too, it's a dead heat.– dragon788
Oct 15 '17 at 5:44
add a comment |
The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.
NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline
, like bash
.
add a comment |
The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.
NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline
, like bash
.
add a comment |
The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.
NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline
, like bash
.
The main advantage is modal editing of your command line. If you're familiar with Vim and likes its philosophy the benefits must be obvious. If you are experienced with it, your finger's muscle memory will make you edit your bash commands in lightning speeds.
NB: If you don't like modal editing, you should still learn to take advantage of the (default) emacs-mode. Here are some nifty keyboard shortcuts that will work on any process with readline
, like bash
.
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Jan 31 '12 at 8:12
rahmu
10.2k1969110
10.2k1969110
add a comment |
add a comment |
If you get used to vi
, so you set it to vi mode as your shell editor. That'd be the obvious reason. The other one is when the bash
is not available by default in some OSes (mostly UNIX like AIX, Solaris), so the shell history feature is not available, so the way you get the past commands by setting the shell editor to vi
, and Esc, Ctrl+K or Ctrl+L
add a comment |
If you get used to vi
, so you set it to vi mode as your shell editor. That'd be the obvious reason. The other one is when the bash
is not available by default in some OSes (mostly UNIX like AIX, Solaris), so the shell history feature is not available, so the way you get the past commands by setting the shell editor to vi
, and Esc, Ctrl+K or Ctrl+L
add a comment |
If you get used to vi
, so you set it to vi mode as your shell editor. That'd be the obvious reason. The other one is when the bash
is not available by default in some OSes (mostly UNIX like AIX, Solaris), so the shell history feature is not available, so the way you get the past commands by setting the shell editor to vi
, and Esc, Ctrl+K or Ctrl+L
If you get used to vi
, so you set it to vi mode as your shell editor. That'd be the obvious reason. The other one is when the bash
is not available by default in some OSes (mostly UNIX like AIX, Solaris), so the shell history feature is not available, so the way you get the past commands by setting the shell editor to vi
, and Esc, Ctrl+K or Ctrl+L
edited Nov 28 '13 at 8:37
Anthon
60.2k17102163
60.2k17102163
answered Oct 30 '13 at 3:20
Shâu Shắc
5041611
5041611
add a comment |
add a comment |
It can let you easily navigate and edit the command line using vim's shortcuts, e.g. quickly move to one word right, delete a word.
By the default shortcuts, when you need to go to the end of the line, you need to Ctrl+e, whereas with set -o vi
, you just hit $
, like in vim.
add a comment |
It can let you easily navigate and edit the command line using vim's shortcuts, e.g. quickly move to one word right, delete a word.
By the default shortcuts, when you need to go to the end of the line, you need to Ctrl+e, whereas with set -o vi
, you just hit $
, like in vim.
add a comment |
It can let you easily navigate and edit the command line using vim's shortcuts, e.g. quickly move to one word right, delete a word.
By the default shortcuts, when you need to go to the end of the line, you need to Ctrl+e, whereas with set -o vi
, you just hit $
, like in vim.
It can let you easily navigate and edit the command line using vim's shortcuts, e.g. quickly move to one word right, delete a word.
By the default shortcuts, when you need to go to the end of the line, you need to Ctrl+e, whereas with set -o vi
, you just hit $
, like in vim.
edited Nov 9 '14 at 4:47
HalosGhost
3,70592235
3,70592235
answered Nov 9 '14 at 4:10
Hahn
1113
1113
add a comment |
add a comment |
Probably late to the party, but for me using the vi mode is more about when creating interactive scrips.. for example
for i in `ls | grep -v gz`
do
echo $i
gzip $i
done
a very simple example of what could be quite complicated.. using ESCkv puts you into a vi session where you can modify the script, and then :wq
and it runs.
1
This may be a good example of using bash invi
mode, but it's a bad example of bash code. (1) Using the output fromls
as the input to any other sort of processing is a bad idea. (2) The$(…)
syntax for command substitution is widely considered to be more readable than the`…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.
– G-Man
Sep 5 '15 at 18:13
add a comment |
Probably late to the party, but for me using the vi mode is more about when creating interactive scrips.. for example
for i in `ls | grep -v gz`
do
echo $i
gzip $i
done
a very simple example of what could be quite complicated.. using ESCkv puts you into a vi session where you can modify the script, and then :wq
and it runs.
1
This may be a good example of using bash invi
mode, but it's a bad example of bash code. (1) Using the output fromls
as the input to any other sort of processing is a bad idea. (2) The$(…)
syntax for command substitution is widely considered to be more readable than the`…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.
– G-Man
Sep 5 '15 at 18:13
add a comment |
Probably late to the party, but for me using the vi mode is more about when creating interactive scrips.. for example
for i in `ls | grep -v gz`
do
echo $i
gzip $i
done
a very simple example of what could be quite complicated.. using ESCkv puts you into a vi session where you can modify the script, and then :wq
and it runs.
Probably late to the party, but for me using the vi mode is more about when creating interactive scrips.. for example
for i in `ls | grep -v gz`
do
echo $i
gzip $i
done
a very simple example of what could be quite complicated.. using ESCkv puts you into a vi session where you can modify the script, and then :wq
and it runs.
edited Sep 9 '15 at 23:22
don_crissti
49.7k15131161
49.7k15131161
answered Sep 5 '15 at 4:04
Walter Werner
111
111
1
This may be a good example of using bash invi
mode, but it's a bad example of bash code. (1) Using the output fromls
as the input to any other sort of processing is a bad idea. (2) The$(…)
syntax for command substitution is widely considered to be more readable than the`…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.
– G-Man
Sep 5 '15 at 18:13
add a comment |
1
This may be a good example of using bash invi
mode, but it's a bad example of bash code. (1) Using the output fromls
as the input to any other sort of processing is a bad idea. (2) The$(…)
syntax for command substitution is widely considered to be more readable than the`…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.
– G-Man
Sep 5 '15 at 18:13
1
1
This may be a good example of using bash in
vi
mode, but it's a bad example of bash code. (1) Using the output from ls
as the input to any other sort of processing is a bad idea. (2) The $(…)
syntax for command substitution is widely considered to be more readable than the `…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.– G-Man
Sep 5 '15 at 18:13
This may be a good example of using bash in
vi
mode, but it's a bad example of bash code. (1) Using the output from ls
as the input to any other sort of processing is a bad idea. (2) The $(…)
syntax for command substitution is widely considered to be more readable than the `…`
syntax. (3) You should always quote shell variables unless you have a good reason not to, and you’re sure you know what you’re doing.– G-Man
Sep 5 '15 at 18:13
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f30454%2fadvantages-of-using-set-o-vi%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown