Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imbilltucker/2edc4eebdec94f06c560f4803433b6fe to your computer and use it in GitHub Desktop.
Save imbilltucker/2edc4eebdec94f06c560f4803433b6fe to your computer and use it in GitHub Desktop.
vim syllabus
= vim syllabus =
== Getting started ==
* Start with the end in mind: `ZZ` or `:q!` or `:qa!`
* from the command line: `vimtutor`
* `:help` <-- also works with argument, e.g. `:help gd`
* to follow links in help: `press enter to follow links`
* plug-ins make help accessible this way, too
* modes of vim
* normal (you're normally in this mode)
* insert
* ex
* visual
* line
* selection
== Motivation ==
* typing .. do you get better over time?
* editing .. do you get better over time?
* improvement requires practice
* break actions into small sub-skills
* frequently review (at least every day)
* text doesn't go away. (Will google docs? evernote always be here??)
* a pervasive interface (vim bindings are in: Sublime, Intellij, atom, emacs [supermacs], vimimium)
* soon neovim will enable embedded vim
* there's a lot to know, you can use it for 20 years and learn something new.
* it's a *powerful* editor:
* macros
* registers
* filetypes
* textobjects
* programmable
* has a grammar: {number}{operation}{motion}
*success starts with sucks*
== Settings ==
* `~/.vimrc` is where these settings go ( may have to be created)
* recommended settings
* spaces, not tabs
* ..
== Editing ==
* basic commands: vimsheet.com
* motions
* char, e.g. `l` (move right one char)
* word, e.g. `b` ( move back one word)
* line, e.g. `k` (move up one line)
* paragraph
* page
* operations
* change {motion}
* find {motion}
* delete {motion}
* composition of motions & operations
* vim's grammar: {number}{operation}{motion}, e.g. `d4w` (delete four words)
* yanking and pasting
* undo
* navigation of undo tree
* autocomplete
* words
* line
* auto-fix your common mistakes
== Navigation ==
* split screens
* mouse=a
* buffers
* tabs
* marks
* codebases (goto definitions, different files and back, formatting)
== using the operating systems ==
* have external commands
* fmt
* uniq
* sort
* `2,$ !sort`
* visual select !sort
== looking for text ==
* regex with in a file
* within line
* within a document
* within all my files
* grep
* vimgrep
* text objects
* inner word: iw, e.g. diw
* inner quotes: i"
* inner paragraph: ip
* tags: it, e.g. cit
* a sentence: as
== macros ==
* saving them
* presetting them
== autocmd ==
* on file save .. for this file type, do <something> (linting, formatting,..etc)
== common things you need to do ==
* what are my misspelled words? `:set spell`
* what files do I have open? `:ls`
* highlight the word I'm looking for. (..and stop it)
* search case-insensitive
* where is this defined?
* sort this text
* reformat this text, `:help gq` or `:'<,'>!fmt` (visual mode)
== vim plugins ==
Leverage someone else's work and organization: use a plug-in. We're all in vim together.
* manage your plugins, here are some common options:
* pathogen
* vundle
* vim-plug
* `vim-airline` # heads up display for vim
* `vimwiki` # organize your knowledge
* `vim-sensible` # sensible defaults for vim
* `vim-commentary` # comment files for most languages all with the same keystrokes
* `ctrl-p` # fuzzy matching for opening files
* `vim-syntastic` # syntax checking
* `utilisnips` # use snippets when you type
* `vim-snippets` # common patterns
== superpowers ==
* using leader to set short-cuts, e.g. `map <leader>s :set spell`
* set spell
* use snippets
* use sessions
* save an editing session: `:mksession <sessionname>`
* restore an editing session: `vim -S <sessionname>`
* tardis-like time machine: `:earlier 5m`, `:later 15s`
* don't forget about:
* `gd` and `^t` for navigating down and back up class structures
* `gf` open file under cursor
* `gq <motion>` auto-format text over the motion
== resources ==
`:help`
Drew Neil's: http://vimcasts.org/
quick examples: https://vimgifs.com/
text objects: http://blog.carbonfive.com/2011/10/17/vim-text-objects-the-definitive-guide/
overview of vi: http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118
vim powers without plug-ins: https://www.youtube.com/watch?v=XA2WjJbmmoM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment