yoaquim / .vim

My personal vim-config, tailored for Javascript development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Vim Config

Intro

This vim configuartion is based off of amix's Ultimate vimrc.

Used some stuff from here too.

You should read through this entire doc in order to successfully set up this vim conf.

I mostly customized it for Javascript development.

I use Adobe's free Source Code Pro font.

You're gonna need npm (comes bundled with Node.js) for some plugins.

And I seriously recommend getting Homebrew, if you haven't already - makes all the extra steps, and installing in general, super easy.

I use Homebrew's vim:

brew install vim

Make sure your usr/local/bin is before your usr/bin in your local $PATH:

export PATH="/usr/local/bin:$PATH"
echo $PATH

Prerequisites

The Ag plugins needs The Silver Searcher in order to work:

brew install the_silver_searcher

Installation

To install:

git clone https://github.com/yoaquim/.vim.git ~/.vim

You're gonna wanna syslink the vimrc file to your actual ~/.vimrc:

ln -s ~/.vim/vimrc ~/.vimrc

Now you need to initialize and update the plugins, which are git submodules:

cd ~/.vim
git submodule update --init --recursive

You should also do this each time you clone any repo that has submodules, or whenever you add a submodule.

If you ever need to update the plugin modules, just do:

git submodule foreach git pull origin master

Settings

  • Load plugin files for file types
  • Load indent files for file types
  • Syntax Highlighting on
  • Set tabs to be 4 spaces: set softtabstop=4 set shiftwidth=4 set expandtab
  • Set updatetime to 1000 milliseconds
  • Set backspace to act as expected
  • Enable mouse (if available)
  • Show command status at bottom
  • Enable line numbers
  • Enable incremental search (search matches as you type)

Plugins

Color Schemes

I'm using base16 color schemes for vim: base16-vim.

Since console Vim can only access colorschemes available to the console/iTerm2, you have to change the console's/iTerm's colorscheme via base16-shell's helper command, that lives in your .bash_profile, in order to change Vim's colorscheme:

# Base16 Shell
BASE16_SHELL="$HOME/.config/base16-shell/"
[ -n "$PS1" ] && \
    [ -s "$BASE16_SHELL/profile_helper.sh" ] && \
        eval "$("$BASE16_SHELL/profile_helper.sh")"

So if you want the dark base16-ocean theme for example, you'd do .../base16-shell/scripts/base16-ocean.sh....

Again, this will change your console/iTerm colorscheme also.

Some shortcuts...

  • Quickly type jk to go to Normal Mode - mapped to Esc('jk' is a rare diagraph in English and you can always wait between typing both chars if you ever need to insert them)

  • :W saves current file as sudo (for when you open a file having no write permissions)

  • :Q force quits, without saving

  • Shift+Tab maps to Ctrl+O, which goes back to previous view/file

  • Alt+j jumps 5 lines down (same as 5j)

  • Alt+k jumps 5 lines up (same as 5k)

  • Shift+Alt+j jumps 15 lines down (same as 15j)

  • Shift+Alt+k jumps 15 lines up (same as 15k)

  • Alt+Shift+. moves the current line up (can also be used in visual mode when selecting blocks/paragraphs)

  • Alt+Shift+, moves the current line down (can also be used in visual mode when selecting blocks/paragraphs)

  • Spell checking: \s

  • Highlight search: \h\h first time you open a file; afterwards, toggle by pressing \h

  • Easier window navigation: Ctrl+h, Ctrl+j,Ctrl+k, Ctrl+l for left, down, up & right, respectively

  • \\ in normal mode turns selected lines into folded code block; toggles fold in normal mode

  • Space acts as leader (\ by default) key. That also allows you to:

    • Space w saves the file (alias to :w); also works with :W version

    • Space q quits vim (alias to :q); also works with :Q version

    • You can copy/paste to system clipboard with <Space> p, <Space> d and <Space> y

    • Enter visual line mode with <Space><Space>

  • Wrap selection in brackets, parenthesis, etc. (view vimrc)

  • Shortcuts for plugins (view vimrc)

About

My personal vim-config, tailored for Javascript development.


Languages

Language:Vim Script 100.0%