-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
103 lines (79 loc) · 2.71 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
" General settings
set nocompatible " Don't maintain compatibility with vi
set backspace=indent,eol,start
set noswapfile
set ruler " Show cursor position
set title " Show file title at the top of terminal window
" Display relative line numbers, with absolute number for current line
set number
set numberwidth=5
set relativenumber
" Search settings
set hlsearch " Highlight all matches. To turn it off, use :noh
set incsearch " When searching, shows patterns typed so far
" Tab settings
set shiftround
set shiftwidth=2
set tabstop=2
" Always use spaces when inserting a <Tab>, so formatting
" won't be messed up if tabstop is changed
set expandtab
" Display extra whitespace
set list listchars=tab:»·,trail:·,nbsp:·
syntax enable
filetype plugin indent on
set textwidth=80 " Break line automatically when reach 81 column
set colorcolumn=+1 " Make 81 column visible
hi ColorColumn ctermbg=5 " Set column color
" Mappings
let mapleader = "\<Space>" " Use space key as leader.
nmap <leader>vr :vsp $HOME/.vimrc<cr> " Split edit vimrc vertically.
nmap <leader>so :source $MYVIMRC<cr>
" Move between wrapped lines without skipping it
nmap j gj
nmap k gk
" Swap 0 and ˆ in order to make easier to move to the first non-whitespace
" character
nnoremap 0 ^
nnoremap ^ 0
" Enable use jk (and kj) to escape from insert mode
imap jk <esc>
imap kj <esc>
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" automatically rebalance windows on resize
autocmd VimResized * :wincmd =
nnoremap <leader>- :wincmd _<cr>:wincmd \|<cr> " Zoom in a vim pane
nnoremap <leader>= :wincmd =<cr> " Zoom out a vim pane
map <leader>i mmgg=G'm " Indent whole file and return cursor to original position
" Specify plugins directory
call plug#begin('~/.vim/plugged')
Plug 'christoomey/vim-tmux-navigator'
Plug 'jgdavey/tslime.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': '.install --all' }
Plug 'junegunn/fzf.vim'
Plug 'thoughtbot/vim-rspec'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
call plug#end()
set background=dark
colorscheme desert
" RSpec.vim mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
" tslime.vim open vim-rspec results in another tmux pane
let g:rspec_command = 'call Send_to_Tmux("bundle exec rspec {spec}\n")'
" FZF settings
nnoremap <C-p> :Files<cr>
let g:fzf_files_options =
\ '--reverse ' .
\ '--preview "(coderay {} || cat {}) 2> /dev/null | head -'.&lines.'"'
" Use ag for listing files. Way faster and no useless files.
let $FZF_DEFAULT_COMMAND = 'ag -g "" --hidden'