-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.vimrc
177 lines (135 loc) · 2.92 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
""""""""""""""""""
"Vim configuration
""""""""""""""""""
"Author: Glynn Forrest
"me@glynnforrest.com
"""""""""""""""""
"General settings
"""""""""""""""""
"Enable highlighting
syntax on
"Enable filetypes
filetype plugin on
filetype indent on
"We're not using vi
set nocompatible
"Don't leave backups everywhere
set nobackup
set nowritebackup
set noswapfile
"Searching wraps around end of file and travels
set wrapscan
set incsearch
set nohlsearch
"Search smartly
set smartcase
set ignorecase
"Line numbers and show where we are
set number
set ruler
"Show our half typed commands
set showcmd
"Indenting properly
set autoindent
set smartindent
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set smarttab
set lbr
set tw=0
"Expand most folds
set foldlevel=5
"Change buffers without saving
set hidden
"Better filename completion
set wildmode=longest,list,full
set wildmenu
set completeopt=longest,menuone
"See the cursor when moving vertically
set scrolloff=4
"Don't redraw while executing macros
set nolazyredraw
"Refresh automatically
set autoread
"Show tabline only when there are more than 1
set stal=1
"Disable alt menu keys so they can be used for mappings
"Use <F10> to open the menu
set winaltkeys=no
colorscheme elflord
"""""""""""""""""""""
" Mappings
"""""""""""""""""""""
"Map the leader to an easy key
let g:mapleader = " "
"Hotkeys to edit and reload .vimrc
map <leader>v :e! ~/.vimrc<CR>
map <leader>V :source ~/.vimrc<CR>
"Quick file write
map <leader>w :w<CR>
vmap <leader>w <ESC>:w<CR>
"Quick file open
map <leader>e :e
"Quick split
map <leader>s :vspl<CR><C-w>w
map <leader>S :spl<CR><C-w>w
"Copy and paste from the system clipboard
map <leader>P "+P
map <leader>p "+p
map <leader>Y "+Y
map <leader>y "+y
"Quick format of file
map <leader>= gg=G<C-o><C-o>
"Navigate up and down a long line
nnoremap j gj
nnoremap k gk
"Scroll a bit faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
"Buffers and tabs
map <left> :bp<CR>
map <right> :bn<CR>
map <leader>x :bd<CR>
map <leader>q :q<CR>
map <leader><space> :tabf %<CR>
map <leader>z :tabclose<CR>
"Window management
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
map <C-,> <C-W><
map <C-.> <C-W>>
"Quick change directory
map <leader>cd :cd
"Change directory to current buffer
map <leader>d :cd %:p:h<CR>
"Move up a directory
map <leader>D :cd ..<CR>
"Ultimate in lazy
map <leader>; :
"Clearer searching
map n nzz
map N Nzz
map * *zz
map # #zz
"Increment everything
set nrformats=alpha,octal,hex
"Toggle line relative line numbers
function! g:ToggleRelativeNumbers()
if(&rnu == 1)
set nu
else
set rnu
endif
endfunc
map <F2> :call g:ToggleRelativeNumbers()<CR>
"""""""""""
"Statusline
"""""""""""
set laststatus=2
set statusline=\ %F%m%r\ %y\ [%{&ff}]\ %l/%L\ %{getcwd()}
"Remembers cursor position in a file
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif