Created
August 10, 2016 01:42
-
-
Save gosukiwi/edca31f8ac385c4de5169bdd08e45906 to your computer and use it in GitHub Desktop.
My vim configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" [ CORE ] ------------------------------------------------------------------ | |
" Very much needed settings to provide a solid base for source code editting | |
" DEPENDENCIES: | |
" - vim-plug: For managing plugins | |
" - ag: The silver searcher | |
" - editorconfig: For projects where common configuration is important | |
" - SourceCodePro: Pretty font for coding | |
" --------------------------------------------------------------------------- | |
" don't make vim compatible with vi | |
set nocompatible | |
" turn on syntax highlighting | |
syntax on | |
" make vim try to detect file types and load plugins for them | |
filetype on | |
filetype plugin on | |
filetype indent on | |
" reload files changed outside vim | |
set autoread | |
" default encoding to utf 8 | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
" enable matchit plugin which ships with vim and greatly enhances `%` | |
runtime macros/matchit.vim | |
" in insert mode, force backspace to delete over line breaks, or | |
" automatically-inserted indentation. | |
set backspace=indent,eol,start | |
" allow to leave unsaved buffers and keep them in the background | |
set hidden | |
" the order in which vim tries the file formats when reading a new file. The | |
" first one is the default for new buffers | |
set fileformats=unix,dos,mac | |
" screen will not be redrawn while running macros, registers or other | |
" non-typed comments | |
set lazyredraw | |
" [ CUSTOMIZATION ] --------------------------------------------------------- | |
" The following are some extra mappings/configs to enhance my personal | |
" VIM experience | |
" --------------------------------------------------------------------------- | |
" use relative line numbers for better j/k navigation | |
set relativenumber | |
" use `,` as mapleader | |
let mapleader = "," | |
" map <leader>v to toggle active buffers | |
noremap <leader>v :b#<CR> | |
" windows-like clipboard | |
" yank to and paste from the clipboard without prepending "* to commands | |
let &clipboard = has('unnamedplus') ? 'unnamedplus' : 'unnamed' | |
" map c-x and c-v to work as they do in windows, only in insert mode | |
vm <c-x> "+x | |
vm <c-c> "+y | |
cno <c-v> <c-r>+ | |
exe 'ino <script> <C-V>' paste#paste_cmd['i'] | |
" save with ctrl+s | |
nmap <c-s> :w<CR> | |
imap <c-s> <Esc>:w<CR>a | |
" allow Tab and Shift+Tab to | |
" tab selection in visual mode | |
vmap <Tab> >gv | |
vmap <S-Tab> <gv | |
" remove the .ext~ files, but not the swapfiles | |
set nobackup | |
set writebackup | |
set noswapfile | |
" search settings | |
set incsearch " find the next match as we type the search | |
set hlsearch " highlight searches by default | |
" use ESC to remove search higlight in normal mode | |
nnoremap <esc> :noh<return><esc> | |
nnoremap <esc>^[ <esc>^[ | |
" most of the time I should use ` instead of ' but typing it with my keyboard | |
" is a pain, so just toggle them | |
nnoremap ' ` | |
nnoremap ` ' | |
" suggestion for normal mode commands | |
set wildmode=list:longest | |
" keep the cursor visible within 3 lines when scrolling | |
set scrolloff=3 | |
" indentation | |
set expandtab " use spaces instead of tabs | |
set autoindent " autoindent based on line above, works most of the time | |
set smartindent " smarter indent for C-like languages | |
" tabs are 2 spaces | |
set shiftwidth=2 " when reading | |
set softtabstop=2 " in insert mode | |
" use 4 spaces for... | |
autocmd FileType php setlocal shiftwidth=4 softtabstop=4 | |
" no lines longer than 80 cols, use this for markdown | |
autocmd FileType markdown setlocal textwidth=80 | |
" use <S-Space> for Vim's keyword autocomplete | |
inoremap <C-Space> <C-n> | |
" On file types... | |
" .md files are markdown files | |
autocmd BufNewFile,BufRead *.md setlocal ft=markdown | |
" .twig files use html syntax | |
autocmd BufNewFile,BufRead *.twig setlocal ft=html | |
" .mustache files use html syntax | |
autocmd BufNewFile,BufRead *.mustache setlocal ft=handlebars | |
" .less files use less syntax | |
autocmd BufNewFile,BufRead *.less setlocal ft=less | |
" .jade files use jade syntax | |
autocmd BufNewFile,BufRead *.jade setlocal ft=jade | |
" .coffee files use coffeescript syntax | |
autocmd BufNewFile,BufRead *.coffee setlocal ft=coffee | |
" when pasting over SSH it's a pain to type :set paste and :set nopaste | |
" just map it to <f9> | |
set pastetoggle=<f9> | |
" select all mapping | |
noremap <leader>a ggVG | |
" use <C-h> abd <C-j> to move lines up and down | |
nnoremap <C-j> :m .+1<CR>== | |
nnoremap <C-k> :m .-2<CR>== | |
inoremap <C-j> <ESC>:m .+1<CR>==gi | |
inoremap <C-k> <ESC>:m .-2<CR>==gi | |
" always display the status line | |
set laststatus=2 | |
" disable Ex mode, never use it anyways | |
noremap Q <Nop> | |
" [ PLUGINS & VISUALS ] ----------------------------------------------------- | |
" Plugin-related configuration | |
" --------------------------------------------------------------------------- | |
" initiate vim-plug | |
call plug#begin('~/.vim/plugged') | |
" -- Generic | |
Plug 'tpope/vim-vinegar' " awesome and simplistic file navigation | |
Plug 'ctrlpvim/ctrlp.vim' " more actively maintained fork of ctrlp | |
Plug 'itchyny/lightline.vim' " lightweight and pure vimscript status bar | |
Plug 'tpope/vim-surround' " visual mode surround | |
Plug 'jiangmiao/auto-pairs' " smart () [] {} matching | |
Plug 'tpope/vim-endwise' " similar to the one above but this one inserts `end` where needed | |
Plug 'editorconfig/editorconfig-vim' " compatibility with .editorconfig files | |
Plug 'ervandew/supertab' " dummy autocomplete in insert mode using <TAB> | |
Plug 'mbbill/undotree' " display a graph of the undo history when needed | |
" -- Web Development | |
Plug 'scrooloose/syntastic' " linters | |
Plug 'mattn/emmet-vim' " emmet/zen-coding | |
Plug 'kchmck/vim-coffee-script' " coffeescript support | |
Plug 'hail2u/vim-css3-syntax' " css3 support | |
Plug 'slim-template/vim-slim' " slim support | |
Plug 'joukevandermaas/vim-ember-hbs' " ember hbs support | |
Plug 'kana/vim-textobj-user' | Plug 'whatyouhide/vim-textobj-xmlattr' " xml tags as text objects | |
" -- Theme | |
Plug 'gosukiwi/vim-atom-dark' " pretty colors | |
" end plugin definition | |
call plug#end() | |
" set light line theme | |
let g:lightline = { | |
\ 'colorscheme': 'wombat', | |
\ } | |
" mappings for ctrlp | |
noremap <leader>b :CtrlPBuffer<cr> | |
noremap <leader>f :CtrlP<cr> | |
" no max files limit | |
let g:ctrlp_max_files = 0 | |
" use ag when seeking files, super fast and ignores .gitignore and such | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" use emmet with <C-E> | |
let g:user_emmet_leader_key = '<c-e>' | |
" set editorconfig-core path | |
let g:EditorConfig_exec_path = '/usr/local/bin/editorconfig' | |
" toggle UndoTree | |
nmap <leader>u :UndotreeToggle<cr> | |
" syntastic settings | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_disabled_filetypes=['handlebars'] | |
" use Adobe's Source Code Pro font | |
set guifont=Source\ Code\ Pro | |
" set the color theme to atom-dark | |
if has("gui") | |
colorscheme atom-dark | |
else | |
colorscheme atom-dark-256 | |
end | |
" make a mark for column 80 | |
set colorcolumn=80 | |
" and set the mark color to lightgray | |
highlight OverLength ctermbg=lightgray guibg=lightgray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment