-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
138 lines (106 loc) · 2.21 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
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'rust-lang/rust.vim'
call vundle#end()
" Custom bindings
cmap w!! w !sudo tee % > /dev/null
nmap ; :
nmap ,<space> :nohlsearch<CR>
nmap <space>w :w<CR>
nmap Q @q
nmap Y y$
imap jk <esc>
imap jj <esc>
nmap <tab> gt
nmap <s-tab> gT
" Navigate splits with Up/Down/Left/Right
map <Up> <C-W>k
map <Down> <C-W>j
map <Left> <C-W>h
map <Right> <C-W>l
vmap > >gv
vmap < <gv
map <space>t :NERDTreeToggle<CR>
map <space>u :call ToggleCursorLine()<CR>
map <space>l :call ToggleNumber()<CR>
map <space>p :call TogglePaste()<CR>
map <space>b :call ToggleBackground()<CR>
" Basic C program
nmap <F2> i#include <stdio.h><CR>#include <stdlib.h><CR><CR>int main()<CR>{<CR>return 0;<CR>}<Esc>
" Basic C++ program
nmap <F3> i#include <iostream><CR>using namespace std;<CR><CR>int main()<CR>{<CR>return 0;<CR>}<Esc>
" Automatically put a shebang on new .sh files
autocmd BufNewFile *.sh :0put='#!/bin/bash'
" Completion
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" Colorscheme
colorscheme solarized
syntax enable
" Indentation
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set copyindent
set smarttab
filetype plugin indent on
" Always display the status line
set laststatus=2
" Searching
set incsearch
set hlsearch
set ignorecase
set smartcase
set history=1000
set undolevels=1000
set title
set novisualbell
set noerrorbells
set belloff=all
set nowrap
set showcmd
set wildmenu
set lazyredraw
set showmatch
set number
set ruler
set backspace=indent,eol,start
set nocursorline
highlight Normal ctermbg=white
set background=light
" Custom functions to toggle stuff
function! ToggleNumber()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
function! TogglePaste()
if(&paste == 1)
set nopaste
else
set paste
endif
endfunc
function! ToggleCursorLine()
if (&cursorline == 1)
set nocursorline
else
set cursorline
endif
endfunc
function! ToggleBackground()
if (&background == 'light')
set background=dark
highlight Normal ctermbg=black
else
set background=light
highlight Normal ctermbg=white
endif
endfunc