Вы находитесь на странице: 1из 14

/first\|second

<pre><code>
,---| emacs-stamp: Time-stamp: <2006-11-07 23:40:22 karl>
| vim-stamp: Latest change: Wed Apr 20 14:27:38 CEST 2011
| .... whichever comes last *ggg*
|
| Title:
vim7-emacs21-cheatsheet of freezing hell
|
... tries to combine the two editors of choice
|
| Author: Karl Voit
| Purpose: learning emacs21 _and_ vim (for myself)
| License: Creative Commons http://creativecommons.org/licenses/by/2.5/
| Status: constantly modified, updated, and expanded
`---Alternative cheatsheet: http://www.elmindreda.org/emacs.html
==============================================================================
==
Editor shortcuts: Emacs and vim
vim
emacs
==============================================================================
==
exit
save
save as

:q
:w
:w!
:w <path/name>

C-x C-c
C-x C-s

save and exit


exit without saving

:wq
:q!

C-x C-s C-x C-c

stop executing things

ESC

open file
file)
open file read only
re-read file (discard changes)
locate file
filter)

:e(dit) file

edit file under cursor

gf

undo
undo
undo
redo
undo

u
:u(ndo)
U
C-r

last changes
one change
latest changes on current line
changes since last save

(or: ZZ)
(or: ZQ)
or

C-c

C-g
C-x C-f

(find-

C-x C-r

:e(dit)!

M-x locate(-with-

repeat last change

append text after cursor


append text after EOL

a
A

insert text after cursor

(goto file)
(or: C-_)

C-_
or
C-x u

C-\

M-x revert-buffer

insert text before first non-whitesp. I


insert file content
:r file
insert line below cursor and insert
insert line above cursor and insert

o
O

join current line and next line

mark char begin


mark paragraph
mark line begin

restore last selection

gv

copy marked part


copy current line

y
yy

paste marked part


"yank"
paste 2nd last content
paste 3re last content

cut marked part


delete marked part

c
d

delete
delete
delete
delete
delete
delete
delete

x
dd
cw
caw
D

(column: C-v|C-q)

C-Space
M-h

char
line
to end of word
current word
to EOL
sentence
paragraph

delete previous
delete previous
delete previous
delete previous
paragraph

C-x i

character
word
sentence
paragraph

"yank"
(or: Y)

M-w
C-S-Backspace
C-y
C-y M-y
C-y M-y M-y
C-w
C-d

(or: :d<num>)
(change word)

or

DEL

M-d
C-k
M-k
M-x kill-paragraph
Backspace
M-Del
C-x Del
M-x backward-kill-

C-w

toggle overwrite/insert mode


replace current char with <char>

INS
r<char>

(or: R)

M-x overwrite-mode

repeat <cmd> X times

X<cmd>

C-u X <cmd>

complete word
complete word backward
complete word forward

C-P
C-N

M-/
M-/
M-/

cancel

C-c

C-g

redraw

C-l

file info
file info (verbose)

C-g
g C-g

set auto indent

:set ai
:set textwidth=0

M-x auto-fill-mode

execute shell code <cmd>

:r(ead) ! <cmd>

show whitespaces

:set list

insert <file>

:r(ead) <file>

M-x insert-file

show document statistics such as


# columns/lines/word/characters/bytes g C-g
--------------------------------------------------------------------------Help
show help of cmd XY
show man-page of current word
grep help

:help XY
K
:helpg foobar

-----------------------------------------------------------------------Buffers
close buffer
close buffer and return to previous
close all buffers but current
buffers
enlarge current buffer

C-w c

:clo(se)

C-w o

:on(ly)

C-x k
C-x 0
M-x kill-someC-x 1

open file for writing


open file for reading

C-x C-f
C-x C-r

change to previous buffer


change to buffer <XY> number <12>
split vertically
split horizontally

C-^
C-6
<12> C-^
<12> C-6
:b <12>
C-w s
:sp(lit)
C-w v
:vs(split)

duplicate buffer

:new

change to (upper) high buffer


change to lower buffer

C-w h
C-w l

list buffers

:ls

edit in new tab


change to next tab
change to previous tab

:tabe(dit) fileA
gt
gT

C-x b
C-x b <XY>

--------------------------------------------------------------------Navigation
goto line <12>
Cursor movements

<12>G
up

left

right

down
buffer begin

M-x goto-line <12>


C-p

C-f

C-f

j
1G

C-n
gg

M-<

buffer end

M->

line begin ... end


line begin (first non-whitespace)

0 ... $
^

C-a ... C-e

word next
word last

w
b

M-f
M-b

sentence previous
sentence next

(
)

M-a
M-e

paragraph begin
paragraph end

{
}

M-{
M-}

goto last place


goto next place (if any)

C-o
C-i

goto begin of last marked part


goto end of last marked part

'<
'>

page up
page down

C-b
C-f

1/2 page up
1/2 page down

C-u
C-d

scroll one line down (keep cursor)


scroll one line up (keep cursor)

C-e
C-y

remember position (as p)


jump to position (p)
jump to last marked position
jump to last place edited
list all marked positions

m p
` p
``
`.
:marks

C-x r m
C-x r b

place current line in the center


"locate"

z.

C-l

M-v
C-v

------------------------------------------------------------ Search and


replace
current
current
current
current

line:
line:
line:
line:

goto character X
fC
goto character X backw. FC
go before character X
tC
go before char. X backw.TC

activate incremental search


search incremental
search incremental backwards
repeat search
repeat search in other direction
filter current buffer with RegEx

:set incsearch
(if activated) /
(if activated) ?
n
N

C-s
C-r
C-s or C-r

replace

s/foo/bar(/gci)

M-%

search word under cursor


search word under cursor backward

*
#

M-x occur

search local variable under cursor


search buffer variable under cursor

gd
gD

search correspondent brace/bracker/.. %


unhighlight the search patterns

:noh

search for regular expressions


/REG
repeat search for reg. expr.
n
search in other directory for reg.ex. N

C-M-s
C-M-s
C-M-r

----------------------------------------------------------------------Spelling
activate spell checking
change spelling dictionary
search for next misspelled word
show correction proposals
add as correct word
add as incorrect word

:set spell
:set spelllang=de
]s
z=
zg
zf

--------------------------------------------------------------------Formatting
lowercase current word
capitalize current word
uppercase current word
toggle case of current word
toggle case of char under cursor

:map
:map
:map
:map
~

<esc>l
<esc>c
<esc>u
<esc>t

viwuW
viwu~W
viwUW
viw~W

quote text
format line
format paragraph
format whole document

gqap
gggqG

shift marked lines to left


shift marked lines to right
set shiftwidth

<<
>>
:set shiftwidth=4

M-l
M-c
M-u

C-c C-q
M-q

------------------------------------------------------------------------Macros
begin recording (name: foo)
end recording

qfoo
q

C-x (
C-x )

execute macro foo


repeat macro execution

@foo
@@

C-x e

edit macro
end edit macro

"ap

save macro
-----------------------------------------------------------------------Columns

mark column begin

C-v

(Windows: C-q)

C-space

set width mark to longest line

copy column(s)
paste column(s)
"yank"
cut column(s)
"kill"

"*y
p

C-x r y

C-x r k

insert column text (foo)

(visual:) Ifoo ESC

C-x r t foo

-------------------------------------------------------------- Folding /
Outline
hide all
show all
toggle hide/show all

zC
zO
zi

C-c C-t
C-c C-a

hide this
show this

zc
zo

C-c C-d
C-c C-s

goto previous
goto next

zk
zj

C-c C-p
C-c C-n

------------------------------------------------------------- Special
Characters
enter carriage return
enter newline
enter spoiler character ^L

C-q ENTER
C-q C-j
C-q C-l

C-q ENTER
C-q C-j
C-q C-l

------------------------------------------------------ Compare/merge
differences
start file A and B in compare mode

vimdiff A B

emerge A B

emacs: goto fast-mode (C-c C-c doesn't have to be used)


emacs: goto edit-mode

C-c C-c f
e

next difference
previous difference
goto difference X

]c
[c

(C-c C-c) n
(C-c C-c) p
C-u X j

change to left file (higher)


change to right file (lower)

C-w h
C-w l

take this version


take other version

:[range]diffpu(t)
:[range]diffg(et)

dp
do

take A-version
take B-version

(C-c C-c) a
(C-c C-c) b

quit without saving the merge


recenter buffers

C-]
l

emacs: http://www.cs.cmu.edu/cgi-bin/info2www?(emacs)Merge%20Commands

---------------------------------------------------------------- Version
Systems
vim: install vcsnursery from http://www.vim.org/scripts/script.php?
script_id=1898
commit changes
show differences between versions
show log of current file
revert changes to most recent version
update current file from repos

:VCSCommit
:VCSVimDiff
:VCSLog
:VCSRevert
:VCSUpdate

C-x
C-x
C-x
C-x

v
v
v
v

v
=
l
u

add file to repos


show annotations
delete file (incl. from repos)
show difference to previous version
view a certain version
show detailed infos

:VCSAdd
:VCSAnnotate
:VCSDelete
:VCSDiff
:VCSReview 42
:VCSStatus

C-x v i

C-x v r

==============================================================================
==
Emacs specific shortcuts:
==============================================================================
==
execute single ELISP command:
increase font size
decrease font size

M-: cmd
C-x C-+
C-x C--

M-: (info "(elisp) Key Binding Conventions")


C-c LETTER ... (only) prefix reserved to user commands
F5..F9
... also reserved to user commands
remove/delete trailing whitespace

M-x delete-trailing-whitespace

interactively build and test regular expressions: M-x re-builder


insert Unicode character (UTF-8): C-x 8 <return>

(ucs-insert)

move between top, bottom, middle of window: M-r


bottom)

(move-to-window-line-top-

count lines/characters in region:

M-=

==============================================================================
==
vim specific shortcuts:
==============================================================================
==
==============================================================================
==
Own vim macros
==============================================================================
==

" move line before boxquote into title field of boxquote


map ,vkbqt kDj6lp0
" remove/delete trailing whitespace:
nmap ;tr :%s/\s\+$//
vmap ;tr :s/\s\+$//
"kill quoted sig
map ,kqs G?^> -- $<CR>d}
" change subject (Subjectaenderung) (Source: Michael Prokop)
map ,vkcs :set nohlsearch<CR>
\:1,/^Subject: /g//s/^\(Subject: \)\(Re: \)\=\(.*\)$/
\\1 (was: \3)/<CR>9<space>i
" simple quote (insert quote after this line)
map ,vksq 0ji<CR><CR><CR><ESC>kki
" quote between line (insert quote in between the line)
map ,vkqbl i<CR><CR><CR><CR><ESC>0kxkkxjxi
" update timestamp (make sure that "set paste" is NOT set
iab Tue Jul 31 13:03:52 CEST 2007 <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
" map ,L 1G/Latest change:\s*/e+1<CR>CYDATE<ESC>
map ,L 1G/Latest change:\s*/e<CR> CYDATE<ESC>
" voit 20070306:
" ESC-c ... capitalize current word (and goto next word)
map <esc>c viwu~W
" ESC-l ... lowercase current word (and goto next word)
map <esc>l viwuW
" ESC-u ... uppercase current word (and goto next word)
map <esc>u viwUW

FIXXME: Bereichsangaben
" Using (g)vim to colorize sourcecode (from:
http://barnson.org/node/295#comment-26758)
" used here: Visual Basic syntax
:cal SetSyn("vb")
:syntax on
:set background=light
:runtime! syntax/2html.vim
ggVG (to select all in this top frame)
"+y (to copy to clipboard)
...................................................................
...................................................................
...................................................................
...................................................................
...................................................................
N O T E S
F O L L O W I N G
...................................................................

...................................................................
...................................................................
...................................................................
...................................................................
Svens Vortrag:
------------------------------------------------------------------------Suchen
------------------------------------------------------ Eingabe von
Sonderzeichen
Eingabe ber ASCII-Nummer:
223 228 246 252
Zwei-Zeichen-Kombination:
Digraph Input! a + : ->
automatische Einrcken (indenting)
Clipboards/Register
Markieren von Text
von Position bis Position
zeilenweise (block)
als Rechteck -> Tabelle
Zeile? DOS/Windows, Unix, oder Mac?
Automatische Erkennung
Beliebige Wahl
%page
Anzeige - Grundlegend
Aktuelle Position des Cursors (Lineal,ruler)
%pause
ASCII-Wert von Zeichen
%pause
Sichtbarmachung von speziellen Zeichen
(TABs, trailing spaces)
:set list -> schon oben drinnen
%pause
geteilte Fenster (horizontal,vertikal)
-> TextKopieren, Vergleiche
%page
Anzeige - Fortgeschritten
Syntax Coloring / Highlighting
%pause
Achtung: ersetzt keinen Parser!
%pause
Struktur der Datei anzeigen - Baumstruktur
Text verstecken

Syntax dependant
Kommandos zum Einklappen und Verstecken
%page
Abkrzungen - Abbreviations
%pause
einfache Wortexpansion:
LS -> Leutheuser-Schnarrenberger
%pause
mehrere Worte:
LT -> Linux-Tag Chemnitz
%pause
mehr als nur Buchstaben:
function_mit_viel_bedeutung(*par1,par2)
* = neue Cursorposition
%pause
mehrzeilige Floskeln:
Sehr geehrter Herr Spammer..
..Aufnahme ins Killfile..
Grnde: [Liste]
Mit freundlichen Gren
%page
Goodies
Autosave
Backup files
Compiler
Filtering
Sessionfile
Syntax Input
%page
Grenzen - Limits
Endlicher Speicher -> Grenzen
Dateigre
Dateinamenlnge
Displaybreite
Zeilenlnge
Zeilenanzahl
Bufferanzahl
Registergre
,---| 2do
`---tabs (vim7)

retab + ersetzen:
:set tabstop=4
:set expandtab
:%retab
^M herauslschen
align-current
query option value

:set OPTION?

folding + examples (emacs-2do-list and vim-2do-list)


mika@grml ~ % grep boxes .vimrc
" 040420 introduced history 8-) and slightly modified 'boxes'-stuff
" 030219 VBlockquote.vim - like the tool "boxes" works ;-)
" 030219 Call boxes - with some funny box-styles ;o)
map ;0 <ESC>:'<,'>!boxes
map ;1 <ESC>:'<,'>!boxes -d boxquote
map ;2 <ESC>:'<,'>!boxes -d peek -a c -s 40x5
map ;3 <ESC>:'<,'>!boxes -d c-cmt
map ;4 <ESC>:'<,'>!boxes -d dog -a c
map ;5 <ESC>:'<,'>!boxes -d simple -a
jr
map ;6 <ESC>:'<,'>!boxes -d headline
--> Test! (FIXXME)
--> boxes = extra-tool!
"boxing" text
title of box

C-c q
C-c w

Snippets einfgen wie zB <a href=""></a>:


:he :iabbrev
:he mapmode-i
(Vim7: C-x C-o)
Ranges: . .+3 % ,. .,$
.........................................................
,---| notes from a former talk:
`---:set tw=50 ... set texxt width
map <c-j> gqip ... macro setzen
:set ft=html
:set paste ... Einfuegen ohne Umformatierung
:set nopaste ...
:set sw<TAB> ... Option vervollstaendigen lassen
:set sw<TAB>=<TAB> ... Option plus Wert vervollstaendigen lassen
:set listchars=tab:,trail:,,eol:$ ... wie sollen list-Elemente usw
visualisiert werden?
:w datei:.neu ... Kopie mit Anhaengsel ".neu" erstellen, Buffer bleibt bei
"datei"

:!ls -l % ... shell-Kommando ls aufrufen (%=aktueller Buffername)


:!<UP> ... letzter Befehl, der mit "!" begonnen hat
C-w n ... C-w=Fensterbefehl, n=new
C-w C-r ... unterster Buffer oben einfuegen (rotate)
:help C-v C-w ... show help on windows-commands (C-v nur um C-w einzugeben)
vimdiff
:diffget ... Aenderungen in den Buffer uebernehmen
%%% vim: ft=mgp ai noet ts=2
-----------------------------------------Emacs und ispell:
;; User-Dictionary ohne Nachfrage speichern
(setq ispell-silently-savep t)
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checking" t)
(autoload 'flyspell-mode "flyspell" "On-the-fly ispell." t)
(setq ispell-program-name "aspell")
;; Initialize spell checking
(setq-default ispell-program-name "aspell")
(set-default 'ispell-change-directory "ndeutsch8-15")
(set-default 'ispell-local-dictionary "ndeutsch8-15")
;; ========================
;; ISPELL
;; ========================
(require 'ispell)
(add-to-list 'ispell-dictionary-alist
'("ndeutsch8-15"
"[a-zA-Z\304\326\334\344\366\337\374]"
"[^a-zA-Z\304\326\334\344\366\337\374]"
"[']" t
("-C" "-d" "german")
"~latin1" iso-8859-15))
;; ========================
;; ISPELL End
;; ========================
;; ========================
;; FLYSPELL
;; ========================
(add-hook 'flyspell-mode-hook
(function (lambda ()
(setq ispell-local-dictionary "ndeutsch8-15")
)))
M-X change-ispell-dictionary
----------------------------------------------------------emacs und LaTeX
Added in file c:\.emacs
(require 'tex-site)

(setq tex-dvi-view-command "C:\texmf\miktex\bin\yap.exe")


(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(TeX-output-view-style (quote (("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%
(o?)dvips %d -o && gv %f") ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)?\\|sema4$" "%(o?)xdvi %dS -paper a4 %d") ("^dvi$" ("^a5\\(?:comb\\|paper\\)?$"
"^landscape$") "%(o?)xdvi %dS -paper a5r -s 0 %d") ("^dvi$" "^a5\\(?:comb\\|
paper\\)?$" "%(o?)xdvi %dS -paper a5 %d") ("^dvi$" "^b5paper$" "%(o?)xdvi %dS
-paper b5 %d") ("^dvi$" ("^landscape$" "^pstricks$\\|^psfrag$") "%(o?)dvips -t
landscape %d -o && gv %f") ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us
%d") ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d") ("^dvi$"
"^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d") ("^dvi$"
"^landscape$" "%(o?)xdvi %dS -paper a4r -s 0 %d") ("^dvi$" "." "%(o?)xdvi %dS
%d") ("^pdf$" "." "\"c:\\Programme\\Adobe\\Acrobat 6.0\\Reader\\AcroRd32.exe\"
%o") ("^html?$" "." "netscape %o")))))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
)
Change target to PDFLaTeX: C-c C-t C-p
Compiled using C-c C-c
C-c
C-c
C-c
C-c

C-s .... section ...


C-e .... environments
C-f C-(b|i|...) ... bold italic
C-c ... compile

http://www.gnu.org/software/auctex/manual/reftex.html
(require 'reftex)
M-x reftex-mode <RET>
C-c
C-c
C-c
C-c
C-c

=
(
)
[
&

(reftex-toc)
(reftex-label)
(reftex-reference)
BibTeX
(reftex-view-crossref)

=== [ ENDE ] ===


-----------------------------------------------------------------------------%%% Local Variables:
%%% mode: outline
%%% outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][09]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[.
+\\]\\)? .*\\)\\|\\(^=== \\[ .* \\] ===.*\\)"
%%% eval: (auto-fill-mode -1)
%%% eval: (flyspell-mode -1)
%%% eval: (end-of-buffer)
%%% eval: (hide-body)
%%% emerge-set-combine-versions-template: "%a\n%b\n"
%%% End:
%%% OLD-outline-regexp: "\\(\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][09]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]\\(\\[\\
(maggie\\|lisa\\)\\]\\)? .*\\)"

%%% OLD-outline-regexp nur "[][] Text": "\\(\\[\\([1-2][0-9][0-9][0-9][0-1]


[0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]\\)?\\]
.*\\)"
%%% OLD-outline-regexp inkl. Sterne als Items: "\\(\\[\\([1-2][0-9][0-9][0-9]
[0-1][0-9][0-3][0-9]\\)?\\]\\[\\([1-2][0-9][0-9][0-9][0-1][0-9][0-3][09]\\)?\\] .*\\)\\|\\(*+ \\)"
</code></pre>

Вам также может понравиться