OSX and Linux
Install Git and cURL. Then run this script from your home folder:
Windows
Install Chocolatey, then install Git and Vim through Chocolatey. Then run this script from your home folder:
Code
See http://gist.github.com/napcs/532968/ for the scripts and code that handle the installation.
My Customizations
Here is a list of customizations I've made with this setup.
A little rusty at Vim? Look at the Vim Command Review at the bottom of this document.
Languages Supported With Additional Tooling
- Ruby
- Elm
- Elixir
- Go
- JavaScript
- HTML
- CSS
- Markdown
Overall settings
- 2 spaces, no tabs, soft and smart tabbing enabled
- Current column and row highlighted
- Red marker at 80 columns
- Uses MyContrast color scheme tested on almost 100 monitors and projectors in various lighting configurations
- Line numbering and syntax enabled
General Customizations
,<spacebar>switches between the two most recent files,sptoggles spell check on and off.zgadds word under cursor to your dictionary
,ltoggles whitespace character visibility,gwill attempt to launch the program for the current file- HTML files open with default browser
- Ruby files run with
ruby - Elixir files run with
elixir - Java files compile and run with
javacandjava - JavaScript files run with
node
,rreloads the Vim configuration,1switches to the previous tab,2switches to the next tabF5toggles highlighted search terms on and offF6on OSX opens the Finder to reveal the folder you're working in,xdeletes the line without saving it to the clipboard,ocreates blank line below cursor without insert mode,Ocreates blank line above cursor without insert mode
Window movement
CTRL+jmoves downCTRL+kmoves upCTRL+hmoves leftCTRL+lmoves right
INSERT mode commands:
jjin INSERT mode will exit INSERT mode and save the filejkin INSERT mode exits INSERT mode
File explorer sidebar
Powered by the NERDTree plugin
,dopens and closes the tree displaying contents of current folder- press
Enterto open the file in the main buffer - press
ito open the file in a horizontal split - press
sto open the file in a vertical split - press
mwhen on a node to get themenuto add, delete, rename files.
- press
This tree always opens to display the root folder of a project if you are using Subversion or Git. Disable the rooter plugin if you don't want this behavior.
Opening Files with a Fuzzy Search
Powered by the Ctrl-P plugin
,fopens the search window. Type part of the filename to locate it.
- Press
Ctrl-KandCtrl-jto go up and down the list - Press
F5to refresh file list
- Press
,bopens search window for buffers only.
Commenting Out Code
Code commenting is powered by NERDCommenter
Use VISUAL mode to select text. Then press:
,ccto comment out selected text,cuto uncomment selected text
Ragtag
Ctrl-x /in insert mode closes the open tag. Press again to close outer tag.
In the following table:
^is the cursor position<C-x>isCtrl+x
| Text | Command | result |
|---|---|---|
<p>^ |
<C-x> / |
<p></p>^ |
p^ |
<C-x> Space |
<p>^</p> |
div^ |
<C-x> Enter |
<div>\n^\n</div> |
^ |
<C-x> @ |
Stylesheet link tag |
^ |
<C-x> $ |
Script tag |
user.name^ |
<C-x> + |
<%= user.name %> |
Markdown
:Tocdisplays a table of contents view for your document in a new Quickfix window
Snippets
Enter a snippet, followed by <Tab>. Based on file types.
HTML
- `html5 generates an html5 skeleton
- 'html5t` generates a simplified HTML5 skeleton
ijsgeneratesscriptblocks for inline JSimagegenerates image tag with altcsslinkgenerates alinktag for CSSjqueryrefgenerates a call to load jQuery from CDNjslinkgenerates link to call external JStextfieldgenerateslabelandinput type="text"textfieldbrgenerateslabelandinput type="text"with a<br>betweentextareagenerateslabelandtextareatextareabrgenerateslabelandtextareawith a<br>betweenemailfieldgenerateslabelandinput type="email"emailfieldbrgenerateslabelandinput type="email"with a<br>betweenselectgenerateslabelandselectand a default<option>selectbrgenerateslabelandselectwith a<br>between, with a default<option>betweennumbergenerateslabelandinput type="number"numberbrgenerateslabelandinput type="number"with a<br>betweencheckboxgenerateslabelandinput type="checkbox"checkboxbrgenerateslabelandinput type="checkbox"with a<br>betweenradiogenerateslabelandinput type="radio"radiobrgenerateslabelandinput type="radio"with a<br>betweenloremdrops in some lorem ipsum text
Grunt
gruntfilecreates skeleton for Gruntfilesgtaskcreates skeleton for a taskgnpmgeneratesgrunt.loadNPMTasksginitconfiggenerates the initConfig code skeletongconfiggenerates thegrunt.configmodular style of configgllgeneratesgrunt.log.writelngwgeneratesgrunt.warngcggeneratesgrunt.config.get
JavaScript
objectgenerates skeleton for object literalobjectkeygenerates the skeleton for an object as a keyanongenerates anonymous functionlistengenerates.addEventListenerkeyvalgenerates a sinple key: value snippetdceisdocument.createElementdgtisdocument.getElementsByTagNamedgiis 'document.getElementById`- 'ac
isappendChild` fois a simple for loop`promptis a prompt boxnumberis theNumberfunctiontofistoFixeddwisdocument.writedw"isdocument.write("")todoputs in a TODO with datestampnoteputs in a NOTE with datestampfixmeputs in a FIXME with datestamp
Notes and Comments
Supported in Ruby, Markdown, JavaScript
todoputs in a TODO with datestampnoteputs in a NOTE with datestampfixmeputs in a FIXME with datestamp
Vim Command Review
Modes
NORMALis the default mode, for navigation, reviewing, and editing documents.VISUALis where you use the keyboard to select characters to cut or copyVISUAL LINEis where you use the keyboard to select lines to cut or copyINSERTis where you type text. In Insert mode, Vim behaves like other editors
Getting out of Insert Mode
Multiple options exist because different keyboards and interfaces exist
ESC returns to Normal mode
CTRL-C returns to Normal mode
CTRL-[ returns to Normal mode
In addition, in this setup, these custom bindings are active:
jkin INSERT mode will exit INSERT mode and return to NORMAL mode.jjin INSERT mode will save the file and then exit INSERT mode and return to NORMAL mode.
Quitting Vim
:q closes the current buffer if it's saved and closes Vim if it's the last buffer
:qa closes all buffers that are saved and closes Vim
:q! closes the current buffer, discarding unsaved changes, and closes Vim if it's the last buffer
:qa! closes all buffers, discarding unsaved changes, and closes Vim
:wq saves the current buffer, closes it, and closes Vim if it's the last buffer
:wqa saves all open buffers, closes them, and closes Vim
Normal mode commands
Moving
Basic movement
hmove one character leftjmove one row downkmove one row uplmove one character rightwmove to beginning of next wordbmove to previous beginning of wordemove to end of wordWmove to beginning of next word after a whitespaceBmove to beginning of previous word before a whitespaceEmove to end of word before a whitespace
Moving quickly
ggmove to first lineGmove to last linenGmove to n'th line of file (n is a number; 12G moves to line 12):n<Enter>move to n'th line of file (n is a number;:12<Enter>moves to line 12)0move to beginning of line^move to first character of line$move to end of lineCtrl-Dmove half-page downCtrl-Umove half-page upCtrl-Bpage upCtrl-Fpage downHmove to top of screenMmove to middle of screenLmove to bottom of screenz.scroll the line with the cursor to the center of the screenztscroll the line with the cursor to the topzbscroll the line with the cursor to the bottom
Editing
xcuts the character under the cursorddcuts the lineyycopies the line (yank line)ppastes after the cursorPpastes in front of the cursoryypduplicates the current line (yank line, paste after cursor)
Getting into Insert Mode so you can type stuff
ienters Insert mode in front of cursoraenters Insert mode after the cursor (appends)Ienters Insert mode at the start of the lineAenters Insert mode after the last character of the line (append line)ocreates a new line below and enters Insert modeOcreates a new line above and enters Insert mode
Rapid edits
diwdeletes inner word. Place cursor on word and activate.ciwchanges inner word, removing word under cursor and placing you in Insert modecitchanges text in an HTML tag, removing the contents between the tags and placing you in Insert modeci"changes text between quotes, removing the contents between the quotes and placing you in Insert mode