Differences between version 56 and previous revision of BashNotes.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 56 | Last edited on Saturday, April 21, 2007 9:58:54 am | by BenStaz | Revert |
Older page: | version 55 | Last edited on Saturday, April 21, 2007 8:43:06 am | by BenStaz | Revert |
@@ -420,12 +420,31 @@
Just do:
*. ~~/.bashrc
+
+!Set vi mode in bash
+
+Vi mode allows for the use of vi like commands when at the bash prompt. When set to this mode initially you will be in insert mode (be able to type at the prompt unlike when you enter vi). Hitting the escape key takes you into command mode. To enable this do:
+
+*set -o vi
+
+One thing I do like about vi mode, is how easy it is to edit really long commands. (Of course some will argue that I should just use a bash script instead)
+
+When in ''vi mode'' press 'esc' to enter ''command mode''. Now press 'v'.
+This will start up the default editor (as defined by the EDITOR environment variable) and your command will be displayed.
+Edit it to your liking (feel free to use multiple lines for loops/if statements etc), save and exit.
+Your command will be executed.
+
+To escape out of ''vi mode'' simply type:
+
+*set +o vi
+
+
!! See also
* CommonErrors, under "Your shell hangs"
* BashOneLiners
* SpacesInPathNames
* PortabilityNotes
* [bash reference manual|http://www.gnu.org/software/bash/manual/bashref.html]