forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
78 lines (64 loc) · 2.78 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
set nocompatible " Use vim settings instead of vi compatible settings
set title " Show the filename in the window titlebar
set number " Enable line numbers
set showmode " Show the current mode
set list " Show “invisible” characters
set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_
set showcmd " Show the (partial) command as it’s being typed
set wildmenu " Enhance command-line completion
set cursorline " Highlight current line
set scrolloff=5 " Start scrolling 5 lines before the horizontal window border
set backspace=indent,eol,start " Allow backspace in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set tabstop=4 " Make tabs as wide as four spaces
set shiftwidth=4
set ignorecase " Ignore case of searches
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set hlsearch " Highlight searches
set incsearch " Highlight dynamically as pattern is typed
set encoding=utf-8 nobomb " Use UTF-8 without BOM
if has('mouse')
set mouse=a " Enable mouse in all modes
endif
" Centralize backups, swapfiles and undo history
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
" Enable syntax highlighting
syntax on
colorscheme molokai
" Enable file type detection
filetype plugin indent on
" Strip trailing whitespace (\ss)
function! StripWhitespace()
let save_cursor = getpos(".")
let old_query = getreg('/')
:%s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace()<CR>
" Save a file as root (\W)
noremap <leader>W :w !sudo tee % > /dev/null<CR>
" Automatic commands
if has("autocmd")
" Treat .json files as .js
autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript
endif
" Auto paste mode on Mac - http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x#answer-7053522
if &term =~ "xterm.*"
let &t_ti = &t_ti . "\e[?2004h"
let &t_te = "\e[?2004l" . &t_te
function XTermPasteBegin(ret)
set pastetoggle=<Esc>[201~
set paste
return a:ret
endfunction
map <expr> <Esc>[200~ XTermPasteBegin("i")
imap <expr> <Esc>[200~ XTermPasteBegin("")
cmap <Esc>[200~ <nop>
cmap <Esc>[201~ <nop>
endif