VI keyboard shortcuts
keyxl.com
VI keyboard shortcuts
1–8 of 8 posts
Re: VI keyboard shortcuts
#2If anyone has something similar for console-mode sam usage I'd love to know that too.
Anyway - the guide:
Ed doesn't push any of the fancy cruft that modern
editors do - full screen views of the text in question
or fiddly mouse interfaces.
It is line based, scriptable, it works *everywhere*
that unix runs, and the default configuration is
predictable. A true power tool from the days of yore
when men were men and each tool did one simple thing
extremely well.
How to get into ed and create some text:
$ touch my_filename
$ ed my_filename
0
a
Here is some text
next line
more
yet more
The dot on the next line indicates I'm done inserting text. Then save and exit.
.
w
q
$
Basic commands:
* a: append to the first line
* p: print the current line
* n: print the current line with a line number (handy)
* %n: list all lines
* 1n: list line one
* 1,5n: line lines one to five
* 5,$n: list lines five until the end
* 2d: delete line two
* 3,4j: merge lines 3 and 4
* 2i: insert text to a new line before the current line 2
* P: enable prompt
* %l: - that's a lower-case letter after 'k' not the
number one. Print all lines, including end-of-line
markers (useful in dos2unix settings among others).
Regular expressions (this is where it gets exciting):
* 2s/next/another/: change the word 'next' on line
two do 'another' (don't forget that trailing slash)
* g/e/: find all the lines containing the letter 'e'
* g/e/n: find all the lines containing the letter 'e'
and then print them out with their line number next
to them.
* %s/e/q/: change the first instance of the letter 'e'
to 'q' on all lines
* %s/e/q/g: change all instances of the letter 'e' to
'q' on all lines
* 1,5s/e/q/3: change the third instance of the letter
'e' to 'q' on all lines
* %v/for/n: print out the lines that do NOT contain
the word 'for'
Other magic:
* 1,4y: cut ('yank') lines 1 to 4
* 5x: paste to after line 5
* 1,3t6: Transfers lines one to three to a position
after line 6.Re: VI keyboard shortcuts
#3Re: VI keyboard shortcuts
#4 d Delete text. (see explanation above)
And where is the explanation?Re: VI keyboard shortcuts
#5No real mention of modality or ranges, only a selection of commands. To call VI commands "keyboard shortcuts" is a bit of a misnomer - they're not shortcuts, they are its interface.
Re: VI keyboard shortcuts
#6* http://www.digilife.be/quickreferences/QRC/Vi%20Reference%20...
* http://www.digilife.be/quickreferences/QRC/vi%20Quick%20Refe...
* http://www.digilife.be/quickreferences/QRC/VIM%20Quick%20Ref...
I am of course from the Emacs camp, so here are some emacs ref cards to complement.
* http://dept-info.labri.fr/~idurand/enseignement/Rebondir/ema...
Re: VI keyboard shortcuts
#7Re: VI keyboard shortcuts
#8This is timely - I wrote an ed guide today and this post is a good opportunity to share it. I've been working on a remote server via ILO-in-a-browser with broken console definitions and a screen that's too small for the interface. It's a gift - I've wanted to be fluent in ed for a long time and spent the time to get there today. If anyone has something similar for console-mode sam usage I'd love to know that too. Any…