Presentation on vi

This is the Presentation on vi given by Jās Eckard on March 9, 2010. This meeting was video recorded, and the video recording can be found at http://www.archive.org/details/UCLUG_March_2010.

The text files launched in vi during this presentation were:
 * 1) this page in plaintext (copy and paste just the text of this page)
 * 2) the wiki markup of this page (click edit at the top and either copy and paste the textbox or use Firefox Add-On  "It's All Text" and launch in gvim)
 * 3) the Constitution of the United States of America (Save Link As...)

= What is vi? =
 * text editor
 * word processor?
 * IDE?
 * modal editor:
 * edit (normal) mode
 * insert mode
 * command mode
 * more

= History =
 * Bill Joy @ Sun
 * "visual" display of
 * now, "class" of editors: ,  ,  ,  , original

= Why? =
 * "on every un*x"
 * "old-school"
 * commands: keyboard:  hand doesn't have to leave
 * not easy to learn, but powerful, most  clones are programmable

= If you learn nothing else = Before yourself you're about to hang, escape colon que bang!
 * mnemonic:
 * mnemonic:

= First =
 * : left/down/up/right movement &rarr; bsdgames
 * : insert mode
 * : edit mode
 * : command ("colon") mode
 * : left/down/up/right movement &rarr; bsdgames
 * : insert mode
 * : edit mode
 * : command ("colon") mode

= Second most important =
 * : undo
 * : redo (vim)

= Motion/Movement =
 * : left/down/up/right
 * : right/left
 * : vim
 * : forward by word (character clump/whitespace)
 * : back by word (ditto)
 * : end of word (ditto)
 * : begin/end of line
 * : column number (zero)
 * : find character (right/left)
 * : find 'til (right/left)
 * : repeat  (forward/reverse)

= Multipliers =
 * almost all commands

= Insert Mode =
 * Don't start out in: more often, altering existing file rather than creating new
 * : insert (at cursor/begin of line non-whitespace)
 * : insert after (cursor/end of line)
 * : create an open line (after/before current line)
 * : replace character
 * : replace "mode"
 * : change (motion/to end of line)
 * : substitute (character/line)
 * : insert/replace mode

= Find =
 * : find regex (down/up)
 * : next (forward/backward)
 * : find word under cursor

= Search/Replace =
 * : substitute
 * : confirm/global/ignore case
 * : entire pattern match
 * : first, second, third, etc. subpattern match
 * : (edit mode)repeat :s

= Editor of the Beast? = ''At this point in the talk, I figured it would get boring, so I added a topical joke. Watch the video for the punchline. -- chruck (Jās)''

= Command mode =
 * : edit file
 * : quit
 * : write
 * : force quit
 * : write and quit
 * : read file, append
 * : execute command
 * : read command, append output
 * : print
 * : global (grep)
 * : current line
 * : zeroth line
 * : last line
 * : all lines
 * : goto line number
 * other  ( / ) commands

= Delete =
 * : delete (motion/end of line)
 * : cross-out character(s) (at/before cursor)
 * : delete word (insert mode)

= Map/Abbreviate =
 * : map (combination of) keys to (combination of) keys ("macro")
 * : abbreviate

= Cut buffer =
 * : yank (motion/line) ("copy")
 * : put (after/before) ("paste")

= Marks =
 * : mark (letter/capital letter)
 * : jump to mark (line/character)

= Miscellaneous =
 * : repeat last action
 * : write & close
 * : change case
 * : equal command
 * : begin of (prev/next) line
 * : high/medium/low (line after/before)
 * : go to line number/last line/first line
 * : file status
 * : paragraph (prev/next)
 * : block (prev/next / beginning/end)
 * : sentence (prev/next)
 * : indent motion (decrease/increase)
 * : filter movement thru program
 * : join
 * : (insert mode) insert - characters
 * : keyword

= Vim-specific =
 * editing beyond insert point
 * folding -
 * - GUI vim
 * - matching word (next/previous)
 * omni-completion
 * plugins
 * syntax highlighting
 * - alternate file
 * - do to all files in file buffers
 * window splitting -
 * equal command
 * visual mode -
 * - goto tag (go back)
 * syntax formatting/indenting
 * spell checking:
 * directory listing
 * remote file editing
 * vim.org
 * syntax formatting/indenting
 * spell checking:
 * directory listing
 * remote file editing
 * vim.org
 * vim.org

= Reference cards =
 * Vim Reference Card
 * vi/vim graphical cheat sheet

= bash =

= Firefox =
 * It's All Text! add-on
 * vim.org Wikipedia syntax files
 * modeline:

= Specific Questions =
 * Language specific settings (setting tab to four spaces automagically when opening any Python file)
 * modeline
 * python syntax files
 * python syntax files
 * python syntax files
 * python syntax files
 * python syntax files
 * python syntax files


 * What is the difference between vi and vim?   I know they're actually pretty stark to a newbie.  I at least know how to do very very crude editing in vim, but couldn't even get into insert mode in vi.
 * vim: Vi IMproved
 * for the most part, vi commands used in vim


 * Search/Replace across multiple files ... perhaps even to files matching a certain pattern only (*.php ... or *template*php ... etc)


 * Auto-completion
 * , omnifunc


 * Auto-tabbing

= Jas' .vimrc file = As promised, here is my  file. It should be documented pretty well, but if you have any questions, type  or ask me. -- chruck (Jās)

" Stuff that I like in vim --Jas " Created by .bashrc.jas JAS_ROX=2009.12.14 " set number set autoindent set autowrite set background=dark set backspace=indent,eol,start set backup set cmdheight=2 set expandtab "if has("foldenable") set foldenable set foldmethod=syntax "endif set history=100 set hlsearch set ignorecase set smartcase set incsearch set joinspaces set modeline set nocompatible set pastetoggle= set printoptions=paper:letter,duplex:off,formfeed:y "  for  set ruler set shiftround set shiftwidth=4 set showcmd set showmatch set tabstop=4 set textwidth=70 set viminfo='20,\"50 syntax on filetype plugin on filetype indent on set formatoptions+=tn set formatoptions-=l " Suffixes that get lower priority when doing tab completion for filenames. " These are files we are not likely to want to edit or read. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out " Add tags file for headers in /usr/include. This should be " generated by .bashrc.jas . set tags+=~/.vim/systags " shortcuts I use: " remap 'gf' to create the file under the cursor if it doesn't exist: map gf :e  " Format current line using 'fmt': map ff !!fmt " Format the comments on the current line using 'fmt': map ff/ !!fmtjI//  map ff# !!fmtjI#  " Join strings from line below: ,J for strings, ;J for comments map ,J JxxX map ;J Jwdw " Format current xml line to be indented: map xml !!XMLLINT_INDENT="   " xmllint --format -dd " *******'s lprintf looks terrible after it has been jasindent'd: map lp JffA "jI           "Jff if has("autocmd") if exists("+omnifunc") autocmd Filetype * \  if &omnifunc == "" | \          setlocal omnifunc=syntaxcomplete#Complete | \  endif endif " To use syntax highlighting with Wikipedia    " (see http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim ) au BufRead,BufNewFile *.wiki setfiletype Wikipedia " When creating new files, base them on the following template    " files: "au BufNewFile *.c so ~/.vim/templates/src.c    "au BufNewFile *.cpp so ~/.vim/templates/src.c     au BufNewFile *.c{,pp} so ~/.vim/templates/src.c     "au BufNewFile *.h so ~/.vim/templates/src.h     "au BufNewFile *.hpp so ~/.vim/templates/src.h     au BufNewFile *.h{,pp} so ~/.vim/templates/src.h     au BufNewFile *.[ch]{,pp} exe "%s/FILE/". expand("%") au BufNewFile *.h{,pp} exe "%s/FILE_/". tr( expand("%"), "a-z.", "A-Z_") au BufWritePre,FileWritePre *.[ch]{,pp} exe "normal ma" au BufWritePost,FileWritePost *.[ch]{,pp} exe "normal 'a" endif