-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
155 lines (110 loc) · 3.35 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
" We don't need to be compatible with Vi
set nocompatible
" Saving and undoing is enough safety for me
set noswapfile
" Looks
" =====
" Turn off extra unecessary GUI stuff:
if has("gui_running")
set guioptions-=T
endif
" Settings
" ========
syntax on
" TODO: Should both of these be set?
filetype plugin on
filetype plugin indent on
" TODO: Make this actually run on start up ><
colorscheme gentooish
" Make ShowMarks behave properly:
let g:showmarks_ignore_type="hpr"
" Set up ignore file types
set wildignore=*.swp,*.bak,*.pyc,*.class
" Set up hard drive saving of undo history
set undofile
set undodir=~/.vim/undo
set number
set ignorecase
set smartcase
set incsearch
set hlsearch
set tabstop=4
set shiftwidth=4
set hidden
" Save on loosing focus
set autowriteall
" Language support:
" ======
let g:pydoc_cmd = "/usr/bin/pydoc"
let g:pydiction_location = '~/complete-dict'
" Omni-Completion tip window to close when a selection is made.
" These lines close it on movement in insert mode or when leaving insert mode.
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
au BufRead,BufNewFile *.json set filetype=json
au! Syntax json source /Users/matias_lange_nielsen/.vim/syntax/json.vim
" Move focus to quick fix window for lint errors in python
let g:pymode_lint_hold = 0
" Automatics
" ==========
" Save on any focus loss
au FocusLost * :wa
if has('autocmd')
autocmd filetype python set expandtab
autocmd BufWinEnter,BufNewFile * silent tabo
endif
" TODO: How to show that this is a fold?
" Mappings
" Make sure <Leader> is configured correctly
let mapleader='\'
" Execute file being edited with <Shift> + e:
map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>
" Bubble single lines
nmap <Up> [e
nmap <Down> ]e
" Removing search highlight on enter (mapping it to esc causes strange issues)
nnoremap <CR> :noh<CR>
" Moving in word-wrapped lines
noremap k gk
noremap j gj
" Bubble multiple lines
vmap <D-Up> [egv
vmap <D-Down> ]egv
" Switch to the last/alternate buffer
noremap <Leader><Leader> <C-^>
" Add line below/above without going to insert mode:
noremap <C-CR> o<Esc>
" Switch to the last/alternate buffer
noremap <S-CR> O<Esc>
noremap <Leader><Leader> <C-^>
" Add line below/above without going to insert mode:
nnoremap TT :TlistToggle<CR>
noremap <C-CR> o<Esc>
map <F4> :TlistToggle<CR>
noremap <S-CR> O<Esc>
" Execute file being edited with <Shift> + e:
" Shorter commands to toggle Taglist display
map <buffer> <F5> :w<CR>:!/usr/bin/env python % <CR>
set pastetoggle=<leader>pt
" Reload vimrc
nnoremap <leader>sv :so $MYVIMRC<cr>
" Map half page up/down
nmap <C-j> <C-d>
imap <C-j> <Esc><C-d>i
nmap <C-k> <C-u>
imap <C-k> <Esc><C-u>i
" Mapping NERDTree
nmap <silent> <leader>t :NERDTreeToggle<CR>
" Refactoring convenience function from https://gist.github.com/048616a2e3f5d1b5a9ad
function! Refactor()
call inputsave()
let @z=input("What do you want to rename '" . @z . "' to? ")
call inputrestore()
endfunction
" Locally (local to block) rename a variable
nmap <Leader>rf "zyiw:call Refactor()<cr>mx:silent! norm gd<cr>[%V]%:s/<C-R>//<c-r>z/g<cr>`x
" Error movement forwards/backwards
nmap <Leader>n :cn<cr>
nmap <S><Leader>n :cp<cr>
nnoremap <S-x> diw
nmap <BS> i<BS><ESC>l