Skip to content

Instantly share code, notes, and snippets.

@jakubgs
Created October 7, 2014 21:15
Show Gist options
  • Save jakubgs/473819148fe273be6560 to your computer and use it in GitHub Desktop.
Save jakubgs/473819148fe273be6560 to your computer and use it in GitHub Desktop.
# Why is Vim So Great?
* Plugins (extensibility)
- plethora of extensions for every need
* Vim Script (customizability)
- configuration files
* Community (maturity)
- thousands of dedicated users and developers
* Built-in Help (Openness)
- extensive help for default vim and all plugins
* Active Development (vitality)
- neovim is the new, better, faster version of vim
# Vi Nature
"Vim is not permanent. Nvi is not permanent. Vi itself is not permanent,
only vi-nature. Emacs has vi-nature, nano has vi-nature, even Notepad
has vi-nature. You narrow your sights, you grow attached, and hence
you do not grasp the true value of your poem’s subject."
- Master Wq, Vim Koans
# Vim Grammar
* Modal nature - Insert mode is not the default mode
* Verbs - Operations you can run on the text
* Nouns - Text objects that you can target
* Modifiers - Specify how far the change should go
* Adverbs - Repeat actions with counts and selection
* Macros - Recordable and modifiable sequences of actions
* Commands - Including whole scripting language inside vim
# Verbs
* i/I - Insert here / Insert at the beginning of line
* o/O - Open after / Open line before
* d/D - Delete / Delete till the end of line
* y/Y - Yank(copy) / Yank till the end of line
* c/C - Change / Change till the end of line
* s/S - Substitute / Substitute whole line
* p/P - Paste after / Paste before
* r/R - Replace char / Replace mode
* ~ - Toggle case
* >> / << - indent
* J - Join lines
# Nouns
* w - word
* W - WORD (includes special characters)
* s - sentence
* p - paragraph
* b - block
* t - tag
* () {} <> [] - block in brackets
* "" '' `` - quoted string
Can by extended with custom text objects and plugins
like targets.vim or vim-textobj-user.
# Modifiers (and motions)
* w/W - word
* e/E - word back
* a - around
* i - inside
* t - till
* f - find
* 0 - beginning of line
* $ - end of line
* gg - beginning of file
* G - end of file
# Adverbs
* Directions:
- arrow keys (BAD!)
- hjkl (Stay in home row!)
* Counts:
- number keys before actions
* Visual selection:
- v - regular selection
- V - line selection
- <c-v> - block selection
* Search:
- / forward regex search
- ? backward regex search
# Macros
* q<reg> - start and end recording macro in <reg>ister
* @<reg> - run recorded macro
All macros are recorded in regular registers,
like any cut or copied text, and can be pasted and modified.
* "ap - paste contents of register a here
* "ayy - copy current line to register a
# Commands
* Regex Substitution:
- :%s/\v(\d+)/<\1>/g - enclose all digits in file in <> brackets
* Global Commands:
- :g/^TEXT/m $ - move all lines mathcing ^TEXT to the end of file
* Buffer Commands:
- :bufdo %s/TEXT//g - remove all occurences of TEXT
from all open buffers
- :argdo g/TEXT/y R - append all lines matching TEXT
into register R from all buffers
in the args list
And many more...
# Getting Started
* .vimrc - main configuration file
* .vim/ftplugin/\*.vim - language specific configuration
* Sane basic config - https://github.com/tpope/vim-sensible
* Insane advanced config - https://github.com/PonderingGrower/dotfiles/
# Help
* :help <word> - search for any command or topic
- : is used for cmdline/Ex-mode commands (:help :help)
- ' is used for options (:help 'incsearch')
- No prefix for normal mode commands (:help CTRL-])
- i\_ for insert mode (:help i\_CTRL-[)
- v\_ for visual mode (:help v\_CTRL-])
# Plugins
Plugin Managers:
* Friendly: https://github.com/Shougo/neobundle.vim
* Simple: https://github.com/junegunn/vim-plug/
* Manual: https://github.com/tpope/vim-pathogen
Plugin Repositories:
* http://www.vim.org/scripts/
* http://vimawesome.com/
* https://github.com/search?utf8=%E2%9C%93&q=vim+plugin
# Plugin Examples
* Git
- Fugitive
- Gitv
* File Fuzzy Searching
- Unite
- CtrlP
- FuzzyFinder
* Movement
- Easymotion
- vim-sneak
* Auto Completion
- NeoComplete
- YouCompleteMe
- SuperTab
* Snippets
- UtilSnips
- NeoSnippet
# Community
* http://www.vim.org/community.php
* http://vim.wikia.com/wiki/Vim_Tips_Wiki
* https://groups.google.com/forum/#!forum/vim_use
* http://vim.1045645.n5.nabble.com/
* http://usevim.com/
* http://www.reddit.com/r/vim/
IRC:
* freenode - irc.freenode.net - #vim
Videos:
* http://derekwyatt.org/vim/tutorials/
* http://vimcasts.org/episodes/archive/
* http://vimeo.com/vimlondon/videos
* https://www.youtube.com/user/MinuteVimTricks
For fun:
* http://www.vimgolf.com/
* http://www.vimgenius.com/
* http://www.vimsnake.com/
* http://vim-adventures.com/
# Active Development
NeoVim - http://neovim.org/
* Refactoring
* Removing unused old code
* Multiprocess support
* Client-Server for eeasilly embeding neovim
* Port all IO to libuv
* JIT Compilation of vimscript to lua
https://github.com/neovim/neovim/wiki/Progress
# End
Thank you for your attention and patience.
________ ++ ________
/VVVVVVVV\++++ /VVVVVVVV\
\VVVVVVVV/++++++\VVVVVVVV/
|VVVVVV|++++++++/VVVVV/'
|VVVVVV|++++++/VVVVV/'
+|VVVVVV|++++/VVVVV/'+
+++|VVVVVV|++/VVVVV/'+++++
+++++|VVVVVV|/VVVVV/'+++++++++
+++|VVVVVVVVVVV/'+++++++++
+|VVVVVVVVV/'+++++++++
|VVVVVVV/'+++++++++
|VVVVV/'+++++++++
|VVV/'+++++++++
'V/' ++++++
++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment