Text Editor Rosetta Stone

In short, most arguments about text-editors are matters of opinion. Being rather open to opinions and able to decipher rubbish versus honest-facts, I figured that this would be an excellent topic to stretch my fingers with. Rather than going 100% off of my personal editing preferences, I am going to build a table of how to perform certain actions of editing from within a few of my favourite editors and let you decide what you prefer. Likewise, this will allow me to have an easy reference for those (rare?) times when I forget how to do things.

I attempted to put the more "standard" commands near the top; however, attempting to group like commands (like all of the different types of cut-to-memory commands) has made this a bit verbose. More is better with this type of information though, so I find being a little bit longwinded with variations here is good, as anyone looking at this page should be well smart enough to figure out how to use their browser's search function to find the portion they wish to view.

If you enjoy this document, you should also check out my grep 1-liners as well as Eric Pement's sed 1-liners

This document just doesn't do justice to folks truly trying to learn vi. You should also check out my learning vi document.

This document released for use under the PPL license available at http://code.dayid.org/ppl/ppl.txt

Not included:
  • aee: not enough information/need to include
  • e3em: see emacs
  • e3pi: see nano
  • e3vi: see vi
  • ee: not enough information/need to include
  • elvis: see vi(m)
  • ex: see vi (& ed for some tasks)
  • jed: not enough information/need to include
  • jove: see emacs
  • mg: see emacs
  • nvi: see vi(m)
  • pico: see nano
  • qemacs: see emacs
  • xemacs: see emacs
  • vile: see vi(m)/mg
  • zile: see emacs

The formatting here is simple enough to understand (I would hope). ^ means ctrl+, so ^x is ctrl+x. M- means meta (generally left-alt or escape)+, so M-x is left-alt+x

Actionedvi(m)emacsnanojoe
quit editorq:q^x ^c^x^c
quit without prompting to save changes madeQ OR
qq
:q!M-x kill-emacs
open file foo.bare foo.bar:e foo.bar^x ^f foo.bar^k e foo.bar
write file to diskw:w^x ^s^o^k s
write file copy to diskw /path/filename:w /path/filename^x ^w
write file and exitwq:wq OR
ZZ
^x ^s ^x ^c^o ^x^k x
undo previous command (that affected buffer)uu^x u OR
^_
^[shift] -
undo last commands that affected current lineU
re-do an undo:^R
insert texti
append texta(start writing)(start writing)(start writing)
append text at end of lineA OR
$a
insert linei (end with . or ^d)O^o
append linea (end with . or ^d)o
move to beginning of line0^a^a
move to first non-whitespace of line^ OR
_
move to first non-whitespace of next line+ OR
^m
move to first non-whitespace of prior line-
move to end of line$ OR
A
^e^b
force write (if read-only but owned by user):w!
print:hardcopy (vim)M-x print buffer
enable syntax hilighting:syntax on (vim)M-x font-lock-mode
cut a line to memoryd:d OR
dd
^[space] at beginning of line
^e to move to end of line
^w to cut selected area OR
^a ^k
^k
visual cut to memoryv (highlight area (hjkl etc)) d^[space] at beginning of area
arrows to move to end of area
^w to cut selected area
^6 to start select
^k to cut
cut current character to memoryx
cut preceeding character to memoryX
cut from cursor to end of line to memoryD OR
d$
cut from cursor to beginning of line to memoryd0 OR
d^
^@ ^a ^w OR
^[space] ^a ^w
cut from cursor to end of word to memorydw (to include following whitespace) OR
de (to cut only word)
M-d
cut from cursor to beginning of word to memorydb
cut # words to memoryd#w
cut multiple lines:d# OR
#dd (where # is the number of lines to cut)
^[space] at beginning of line
^n to go to next line
^e to move to end of line
^w to cut selected area OR
M-1 M-2 ^k (cuts 12 lines) OR
^k (repeat for all lines to be cut)
^k (repeat for all lines to be cut)
replace current cursor letter with XrX
replace word from cursor positionce
replace # words from cursor positionc#w
replace from cursor position to end of linec$
mark a positionmX
where X is [0-9a-zA-Z]
M-x bookmark-set OR
^x r m OR
M-x set-mark-command OR
^@
move cursor to marked position`aM-x bookmark-jump OR
^x r b OR
^x ^x
return to point prior to going to marked position^x ^x
move cursor to first non-whitespace on line with mark X'X
delete from marked position to cursord`X
paste a line from memoryp OR
:p (below current line - pending mode)
P OR
:P (above current line - pending mode)
^y^u
append next line to current line (join)jJ
search for prior text string$string^r
search for next text string/string/string^s string^w string^k f
move cursor to next occurrence of string/ OR
n
^s
move cursor to prior occurrence of stringN
print all occurrences of stringg/string OR
g/string/p
g/string
find and replace the first occurrence of stringA with stringB on current lines/stringA/stringB:s/stringA/stringB
find and replace all occurrences of stringA with stringB on current lines/stringA/stringB/g:s/stringA/stringB/g
add "confirmation" to each find/replace for multiple occurrencesappend "c" after /, e.g., s/stringA/stringB/gcdone by default
find and replace all occurrences of stringA with stringB%s/stringA/stringB/g OR
,s/stringA/stringB/g
:%s/stringA/stringB/gM-%
stringA
stringB
!
^\
stringA
stringB
a
find and replace all occurrences of stringA with stringB from line X to line YX,Ys/stringA/stringB/g:X,Ys/stringA/stringB/g
find and replace all occurrences of stringA with stringB from line X to last lineX,$s/stringA/stringB/g:X,$s/stringA/stringB/g
find and replace all occurrences of stringA with stringB from current line to last line.,$s/stringA/stringB/g:.,$s/stringA/stringB/g^k f
[stringA]
r
[stringB]
r
move cursor to line ##:# OR
#G
M-g g # OR
M-x goto-line
#
^_#^k l#
print current line #n^g
move cursor to character "mate" (e.g., other closing/opening brackets - good for programming)%^M-f and ^M-b
move cursor left one characterh^f^b
move cursor right one characterl^b^f
move cursor up one line-k^p^p
move cursor down one line[enter] OR
+
j^n^n
move cursor up X lines-X OR
-----
(where number of -'s = X)
Xk^u X ^p
move cursor down X lines+X OR
+++++
(where number of +'s = X)
Xj
move cursor left X charactersXh
move cursor right X charactersXl
move cursor right one wordwM-b
move cursor left one wordbM-f
move cursor to bottom of screenL
move cursor to middle of screenM
toggle case of current character~
access helph:h OR
:help
^h ^h^k h
toggle help/error message displayH
access tutorialvimtutor (vim only, separate stand-alone)^h t
print all lines in file,p
print from current line to line Y (any set current line to Y).,Yp
print from line X to line Y (and set current line to Y)X,Yp
print from line X to last line (and set current line to last);p
split editing window horizontally ^x 2
split editing window vertically^x 3
remove all window splits (1 window)^x 1
switch to next window^x o
sort file:sort
go to next page^v
go to previous pageM-v
center screen on cursor location^l
go to beginning of document1G OR :1 OR ggM-<M-\ or M-|
go to end of documentGM->M-/ or M-?
replace current buffer with output of command:%!command
execute command from within editor:!command
print current line (line-editor style)p or .
start irc clientM-x irc