-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
158 lines (139 loc) · 4.98 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
" This must be first, because it changes other options as side effect
set nocp
""""""""""""""""""""""""""
" pathogen init
""""""""""""""""""""""""""
execute pathogen#infect()
syntax on
filetype plugin indent on
""""""""""""""""""""""""""
" solarized - Colorscheme
""""""""""""""""""""""""""
syntax enable
set background=dark
colorscheme ego
set t_Co=256
""""""""""""""""""""""""""""
" aktuelle Zeile hervorheben
""""""""""""""""""""""""""""
set cursorline
hi cursorline cterm=none term=none
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
highlight CursorLine guibg=#303000 ctermbg=234
""""""""""""""""""""""""""""""""""""""""""""""""
" Centralize backups, swapfiles and undo history
""""""""""""""""""""""""""""""""""""""""""""""""
set backupdir=~/.vim/backups
set directory=~/.vim/swaps
if exists("&undodir")
set undodir=~/.vim/undo
endif
""""""""""""""""""""""""""
" Keybindings
""""""""""""""""""""""""""
let mapleader = "\<Space>"
" Type <Space>q to close file
nnoremap <Leader>q :q<CR>
" Type <Space>w to save file
nnoremap <Leader>w :w<CR>
" Type <Space>o to open a new file
set wildignore+=*/node_modules/*
set wildignore+=*/vendor/*
set wildignore+=*/bower_components/*
nnoremap <Leader>o :CtrlP<CR>
" Enter visual mode with <space><space>
nmap <Leader><Leader> V
" Go to tab by number
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
""""""""""""""""""""""""""""""""
" Moving lines and selections with Ctrl-J and K
"""""""""""""""""""""""""""""""""
nnoremap <leader>k :m-2<cr>==
nnoremap <leader>j :m+<cr>==
inoremap <leader>j <esc>:m+<cr>==gi
inoremap <leader>k <esc>:m-2<cr>==gi
vnoremap <leader>j :m'>+<cr>gv=gv
vnoremap <leader>k :m-2<cr>gv=gv
" auto-close { and place cursor
inoremap {<CR> {<CR>}<C-o>O
"""""""""""""""""""""""""""""
" improved search and replace
"""""""""""""""""""""""""""""
vnoremap <silent> s //e<C-r>=&selection=='exclusive'?'+1':''<CR><CR>
\:<C-u>call histdel('search',-1)<Bar>let @/=histget('search',-1)<CR>gv
" search for visually selected text
vnoremap // y/<C-R>"<CR>
""""""""""""""""""""""""""
" my config
""""""""""""""""""""""""""
set smarttab
set tags=tags
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set laststatus=2
set timeout timeoutlen=200 ttimeoutlen=100
set visualbell " don't beep
set noerrorbells " don't beep
set autowrite " Save on buffer switch
set showcmd
set scrolloff=3
set encoding=utf-8
set colorcolumn=85
set pastetoggle=<F10>
" Open splits
nmap vs :vsplit<cr>
nmap :sp :rightbelow sp<cr>
" Nerdtree
nmap <C-b> :NERDTreeToggle<cr>
nmap <F6> :NERDTreeFind<cr>
" move betwwen splits
nnoremap <C-j> <C-W><C-J>
nnoremap <C-k> <C-W><C-K>
nnoremap <C-l> <C-W><C-L>
nnoremap <C-h> <C-W><C-H>
" Quickly go forward or backward to buffer
nmap :bp :BufSurfBack<cr>
nmap :bn :BufSurfForward<cr>
highlight Search cterm=underline
autocmd cursorhold * set nohlsearch
autocmd cursormoved * set hlsearch
" strip trailing whitespace
autocmd FileType javascript,html,php,css,vim autocmd BufWritePre <buffer> StripWhitespace
" Convert Tabs to Spaces
autocmd BufWritePre <buffer> retab
""""""""""""""""""""""""""""""""""""""""""""""
" automatically jump to end of text you pasted
""""""""""""""""""""""""""""""""""""""""""""""
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" select pasted text
noremap gV `[v`]
" show tags
nmap <F8> :TagbarToggle<CR>