Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Power of Vim

Dima Chumak
February 10, 2013

The Power of Vim

The idea behind this slides is to provide overview and reference of most useful vim commands, many of which are not known to or forgotten by an average vim user. It also describes a "must have" and "best of" vim plugins (general-purpose and targeted for C/C++ programming) of my choice.

Dima Chumak

February 10, 2013
Tweet

Other Decks in Programming

Transcript

  1. Links • vim.org - main site: docs, plugin search •

    vim.wikia.com - vim tips collection • ru.wikibooks.org/wiki/Vim • vimcasts.org - collection of video tutorials • vim-scripts.org - all vim plugins under git • rayninfo.co.uk/vimtips.html Best of Vim Tips by David Rayner a.k.a. zzapper, 15 years with Vim and still learning ;) • derekwyatt.org/vim/vim-tutorial-videos Derek Wyatt's Vim video totorial
  2. . .

  3. i I gi a A o O R gh gH

    v_Ctrl-g v V Ctrl-v
  4. h j k l H M L ( ) {

    } w W b B e E ge gE 0 $ ^ g_ g0 g$ gj gk f F t T ; , | gm / ? * # g* g# n N gg G ` ' [ ] %
  5. r R dl x D dd Y yy p P

    [p [P s S C cc J
  6. iw iW aw aW is as ip ap it at

    ib ab i( a( i) a) iB aB i{ a{ i} a} i< a< i> a> i" i' i` a" a' a`
  7. named marks (user): `{a-z} `{A-Z} [` ]` special marks (auto):

    `{0-9} `` `" `^ `. `[ `] `< `> `( `) `{ `}
  8. function(int a) +-> { | if (a) | +-> {

    [[ | | for (;;) --+ | | +-> { | | [{ | | foo(32); | --+ | | [{ | if (bar(a)) --+ | ]} | +-- | +-- break; | ]} | | | } <-+ | | ][ +-- foobar(a) | | } <-+ | } <-+
  9. int func1(void) { return 1; +----------> } | [] |

    int func2(void) | +-> { | [[ | if (flag) start +-- +-- return flag; | ][ | return 2; | +-> } ]] | | int func3(void) +----------> { return 3; }
  10. [( <-------------------------------- <------- if (a == b && (c ==

    d || (e > f)) && x > y) --------------> --------------------------------> ])
  11. +-> +-> /* | [/ | * A comment about

    --+ [/ | +-- * wonderful life. | ]/ | */ <-+ | +-- foo = bar * 3; --+ | ]/ /* a short comment */ <-+
  12. +-> #ifdef USE_POPEN [# | fd = popen("ls", "r") %

    +-- #else ]# | fd = fopen("tmp", "w") +-> #endif
  13. [[ ]] [] ][ [{ ]} [( ]) [c ]c

    [m ]m [s ]s [z ]z [' ]' [# ]# [/ ]/
  14. :filetype plugin on :filetype indent on :syntax enable :set nocompatible

    :set ignorecase smartcase :set hlsearch incsearch nowrapscan :set foldmethod=syntax :set autoindent nocindent nosmartindent :set tabstop=4 shiftwidth=4 expandtab :set laststatus=2 :set showmode showcmd wildmenu :set listchars=eol:$,tab:>-,trail:. :set nowrap winminheight=0 novisualbell :set backup backupdir=~/.vim/backup :set undofile undodir=~/.vim/undo :set relativenumber :set confirm nohidden :set history=5000
  15. Vim directory structure ~/.vim |-- after |-- autoload |-- colors

    |-- doc |-- ftplugin |-- plugin `-- syntax
  16. pathogen Revolution in vim plugin management Makes it super easy

    to install plugins in their own private directories Check out the how to and video tutorial on vimcasts.org
  17. vundle Takes ideas behind pathogen and brings it to the

    next level Inspired by Ruby's bundler gem
  18. vim-scripts.org Mirrors all vim plugins under git on Github vim-scripts.org

    + git submodules + pathogen OR vim-scripts.org + vundle = automatic plugin management, updates and synchronization
  19. FuzzyFinder Provides convenient ways to quickly reach the buffer, file,

    command, bookmark, tag you want, using fuzzy pattern matching
  20. yankstack Lightweight implementation of the Emacs 'kill ring' for Vim.

    It allows you to yank and delete things without worrying about losing the text that you yanked previously. It effectively turns your default register into a stack, and lets you cycle through the items in the stack after doing a paste.
  21. EasyMotion Highlights all possible motion choices and allows you to

    press one key to jump directly to the target
  22. Align Easily align text and program code in various ways,

    using multitude of predefined align-schemas or powerful manual control
  23. DirDiff Performs a recursive diff on two directories and generates

    a diff window, similar to GUI diff tools like Kdiff3 or Kompare
  24. man Allows to read man pages directly from vim with

    :Man command This plugin is part of default vim distribution and can be enabled with runtime! ftplugin/man.vim command in .vimrc
  25. Taglist Provides an overview of the structure of source code

    files and allows you to efficiently browse through source code files for many programming languages
  26. Tagbar Similar to the Taglist plugin, but is superior in

    some ways and provides an ability to sort tags by scope
  27. Tagselect A better :tselect and Ctrl-] commands Shows matched tags

    in a separate window, which can be searched and scrolled with ordinary vim commands
  28. clang-complete Uses Clang for completing C, C++, Objective-C and Objective-C++

    You don't need any ctags for it to work It can complete complex things, which OmniCppComplete can't
  29. delimitMate Provides automatic closing of quotes, parenthesis, brackets, etc., besides

    some other related features that should make your time in insert mode a little bit easier
  30. Syntastic It's a syntax checking plugin that runs files through

    external syntax checkers and displays any resulting errors to the user This can be done automatically or on demand
  31. git_patch_tags Provides shortcuts for adding tag lines for git commits,

    like Reviewed-by: Tested-by: etc. with automatic user-name and email substitution
  32. patchreview Simplify the process of reviewing multi-file patches, by showing

    each file changes in a diffsplit in separate vim tab
  33. ShowMarks Visually shows the location of marks by placing a

    sign in the leftmost column of the buffer
  34. deb Allows to browse debian package in the same way

    you can browse .tar and .zip files
  35. Give it a try ;) Check out my .vimrc config

    on github To try my vim configuration just do the following: $ git clone git://github.com/chumakd/vim-runtime.git $ cd vim-runtime $ git submodule update --init $ cd .. $ MYVIMRC=./vim-runtime/vimrc VIMHOME=./vim-runtime \ gvim ./vim-runtime/vimrc
  36. F!N