Workshop "Editing with Vim" 2016-04-29 Grazer Linuxtage http://www.guckes.net/graz2016/workshop.editieren_mit_vim.txt Latest change: Thu May 05 16:23:42 CEST 2016 size: ca 310 lines, 7KB DE: = das wichtigste EN: = the most important DE: undo+redo (rückgängig+vorwärts) EN: undo+redo (back+forth) u undo :help u ^R redo CTRL-R -> :help CTRL-R DE: Wiederholung der Änderung mit dem Punkt EN: repeat last change with the dot dd delete current line . repeat last change DE: BEWegen.. Sprünge EN: moving about... JUMPS wörtern/words: aus buchstaben b wort-anfang backwards e wort-Ende w wort-anfang WÖRTERN/WORDS: aus nicht-leeren zeichen B wort-anfang backwards E wort-Ende W wort-anfang H home links oben M middle mittlere zeile L last line letzte zeile DE: Nummernpräfix -> wiederholt Kommandos EN: number prefix -> repeats command :set sc showcmd Show (partial) command in the last line of the screen. 3W three times: jump to next beginning-of-word 3dd three times: delete current line 3p three times: put text from default register 23G jump to line 23 G jump to line last :set nu numbers anzeigen :set ru "ruler" column+line 3u three times: undo -> undo last three changes 9^R nine times: redo -> redo nine undone changes N| jump to column N DE: Kommandokombinationen (cdy + bewegung) EN: command combinations (cdy + jumps) yy copy current line dd delete current line cc change current line -> S y3w "yank three words" -> |:reg "| d3w "delete three words" c3w "change three words" d80G eins zwei drei sieben acht neu zehn "change": first delete text - and then switch to insert mode C ----> c$ c$ change to end-of-line (EOL) D ----> d$ d$ delete to end-of-line (EOL) Y ----> y$ y$ copy/yank to end-of-line (EOL) dG löscht an den ende des Puffers DE: Kommandozeile (ex editor) EN: Command Line (ex editor) :M,Nc von der zeile M bis zur zeile N mache kommand c :23,42d :1,$d :%d :%s/foo/bar/g :.-23,/foobar/+3s/.../ DE: Register (Clipboards) EN: registers aka clipboards use quotes and a letter to say "use this register now" - and then copy/delete or yank some text. p put/paste einfügen aus dem default register/clipboard "x use register 'x' "ddd use register 'd' to delete current line into into register 'd' delete current line "dp use register 'd' to paste from from register 'd' - paste! % current filename : last command line / last search pattern "" name of default register use CTRL-R in insert mode to *read* in contents of a register. standard-texte, signatur, telephonnummer."" 0179-3966141 :reg viminfo session file TODO DE: visuelles Markieren; operatoren anwenden EN: visual selection; apply operators v select visually from start to end ("VISUAL) V select visually by complete lines ("VISUAL LINE") ^V select visually by rectangle block ("VISUAL BLOCK") The Vim editor is based on Stevie and includes (ideas from) other software, worked on by the people mentioned here. Other people helped by sending me patches, suggestions and giving feedback about what is good and bad in Vim. operators: y yank (copY) d delete x delete c change g? rot13 ! filter gv goto visual - select last visual text -> :help visual-operators DE: Filter ("die shell ist dein freund") EN: filtering ("the shell is your friend") change contents of first line: :1!date change contents of current line: !!date -> :.!date note: input is irrelavant to "date" try it on this line with "cowsay": moo note the difference: calling subshell: :!date :!ls -l % g^G = g + CTRL-G DE: = Pasting, Abkürzungen, Binding, Wörterbuch, Tags EN: = Pasting, Abbreviations, Binding, Dictionary, Tags DE: Einfügen (":set paste", pastetoggle) EN: pasting (":set paste", pastetoggle) p paste *after* current position P paste *before* current position :set paste :set paste! :map :set paste! :set pastetoggle= copy some text and insert with "Shift-Insert" DE: Abkürzungen (wort -> LANGESWORT) EN: Abbreviations (word -> longword or phrase) :iab moo eine Kuh macht Muh :iab mysign Sven Guckes [www.guckes.net] NB: die Expansion erfolgt nicht am Ende der Eingabe des letzte Zeichens der Abkürzung, sondern erst nach der Beendigung der Abkürzung durch die Eingabe eines weiteren nicht-Buchstabens (zB Leerzeichen) DE: :map - "Mappen" von Kommandos EN: :map - Command "mappings" :map ,, :w :imap ,, :w :map ,h :set hls! :map ,l :set list! :map ,n :set nu! :map ,p :set paste! :map ,w :set wrap! :nmap >ip :nmap :%s/\s\+$// :nmap vip:s/ \+/ /g :map :set cul! cuc! DE: Wörterbuch und Präfixexpansion EN: dictionary and prefix expansion :set dict=~/.vim/dictionary :e ~/.vim/dictionary DE: Lesezeichen -> tags Datei EN: bookmarks file -> tags file :set tags=~/.vim/mytags :e ~/.vim/mytags tag TAB file TAB command dict ~/.vim/dictionary /^ :ta dict DE: = Aufgaben EN: = Tasks DE: Textobjekte: worte WORTE Satz Absatz EN: Text Objects: words WORDS sentence paragraph move current word/sentence/paragraph TODO write paragraph DE: Absatz nach Textbreite neu formatieren EN: reformat paragraph to current textwidth built-in text reformatting :set fo=cqrt this is a ragged text. different lengths of lines. make them fit according to current text width. you can do it. just use vim. gqip! yo! :set tw=42 gqip :set tw=50 > this is cited text > from someone else. this is what i wrote. it's my text - see? DE: Zeilen kommentieren (visual block mode + Insert) EN: comment lines (using visual block mode + Insert) DE: Spaltenblöcke versetzen EN: switch blocks of columns DE: Block filtern (zitieren, cowsay) EN: filter block (citation, cowsay) DE: Textblock sortieren (numerisch) EN: sorting a block (numerically) 2016 42 0815 1967 4711 23 DE: mit Fenstern arbeiten (öffnen, teilen, schließen) EN: working with windows (open, split, close) :new CTRL-W n :split CTRL-W s :close CTRL-W c DE: zwischen Puffern wechseln (:ls, :b; :bn, :bp) EN: switching between buffers (:ls, :b; :bn, :bp) :ls :bn :bp :b 23 :b foo gf goto current filename ("under cursor") q: :q close DE: = eventuell EN: = maybe DE: Suchen+Ersetzen mit REs EN: search+replace with REs :%s/\s\+$// DE: viminfo - Session abspeichern EN: viminfo - store current session :set vi=\"200,%,'200,/100,:100,@100,f1,h,n~/.vim/viminfo DE: Farben setzen EN: setting colors syn keyword MyTyposDE bscihen bracuht doer nciht hi MyTyposDE ctermfg=white ctermbg=red syn match MyDONE "\" hi MyDONE ctermfg=red ctermbg=black syn match MyTODO "\" hi MyTODO ctermfg=white ctermbg=red TODO DONE DE: TABs or SPACEs? TABs expandieren! EN: TABs or SPACEs? expand TABs! the problem: http://www.guckes.net/cartoons/tabs_or_spaces.png :set list :set listchars=tab:»·,trail:·,eol:$ :set expandtab :set et :retab shortest form: :se et|ret homework: map it to F11 DE: mit TABs arbeiten EN: using TABs - or not at all ;) :tabnew :tabnext :tabprevious :map [6~ :tabn :map [5~ :tabp :tabs DE: mit Folding arbeiten EN: using folding ... DE: ... EN: switching to insert mode A $a I ^i 0i CTRL-O CTRL-I vim: set et ft=sven tw=999 nowrap: THPXRF EOF