aboutsummaryrefslogtreecommitdiff
path: root/vimrc-old
blob: c5bd4e6173b68aaa6d34bb2f9dcbb7dfbcb165ef (plain)
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
" vi:columns=160:list:ts=2:sts=2:sw=2
"================================================================================
" Vundle: plugin manager...
set nocompatible                                      | " do not try to be vi, be vim (required by Vundle)
filetype off                                          | " Vundle needs this
set rtp+=~/.vim/bundle/Vundle.vim                    | " set runtimepath (required by Vundle)
call vundle#begin('~/.vim/bundle/')                  | " location where Vundle searches&installs plugins

" Plugin dependant configurations...
Plugin 'tpope/vim-sensible'                           | " a sane and modern default configuration 
Plugin 'tpope/vim-fugitive'                           | " the most complete GIT integration plugin
Plugin 'tpope/vim-surround'                           | " plugin makes cs"' inside a line replace " with '
Plugin 'tpope/vim-repeat'                             | " lets . (dot) repeat plugin macros as well, specifically vim-surround
Plugin 'tpope/vim-vinegar'                            | " Improves :Explore
Plugin 'tpope/vim-characterize'                       | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values)

Plugin 'tpope/vim-vividchalk'                         | " dark theme
Plugin 'nelstrom/vim-mac-classic-theme'               | " light theme

Plugin 'Valloric/YouCompleteMe'                       | " syntax checker and code completion
Plugin 'cscope_plus.vim'                              | " run cscope -R -b in project folder then use
Plugin 'autoload_cscope.vim'                          | " CTRL+\ s searches word under cursor, CTRL+T back
Plugin 'jeaye/color_coded'                            | " semantic highlighting with vim
Plugin 'terryma/vim-multiple-cursors'                 | " displays visual block mode as cursors
Plugin 'taglist-plus'                                 | " quick code navigator
Plugin 'jdonaldson/vaxe'                              | " code completion for haxe
Plugin 'sheerun/vim-polyglot'                         | " better syntax highlighting/indentation for multiple languages
Plugin 'loremipsum'                                   | " Sample text generator
Plugin 'vim-airline/vim-airline'                      | " beautification of the mode line
Plugin 'nathanaelkane/vim-indent-guides'              | " shows indentation guidelines by pressing <leader>ig 
Plugin 'gregsexton/matchtag'                          | " highlights closing ML tags like braces 
Plugin 'indenthtml.vim'                               | " works better with mixed html/css/javascript
Plugin 'easymotion/vim-easymotion'                    | " speed up navigation: try \\w or \\f, then one of the highlighted chars
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/vimshell.vim'
Plugin 'jeetsukumaran/vim-buffergator'                | " switch buffers with \b or <\-Left> <\-Right>

let g:airline_powerline_fonts = 1

let Tlist_Compact_Format = 1                          | "
let Tlist_GainFocus_On_ToggleOpen = 1                 | "
let Tlist_Close_On_Select = 1                         | "

Plugin 'VundleVim/Vundle.vim'                         | " Vundle itself (required)
let g:ycm_global_ycm_extra_conf = '~/.vim/ycm_extra_conf.py' | " fallback, right one should be in the applications path
let g:ycm_confirm_extra_conf = 0                      | " disable 'do you really want to execute .py?'
let g:ycm_key_select_completion = '<Tab>'             | " key completion key
let g:ycm_error_symbol = '✖'                          | " insert this as an error symbol in the gutter bar
let g:ycm_warning_symbol = '➔'                        | " insert this as a warning symbol in the gutter bar
let g:ycm_collect_identifiers_from_tags_files = 1     | "
let g:ycm_autoclose_preview_window_after_insertion=1  | " close the window when leaving insert mode
"let g:ycm_semantic_triggers = {'c' : ['(', ',']}     | " add additional triggers (not recommend)

let b:html_omni_flavor='xhtml'                        | " prever xhtml over html because that makes inline php code possible without hassle
let html_use_css = 1                                  | " when using :TOhtml no font-tags will be used, but proper css
let g:vim_markdown_folding_disabled=1                 | " disable code folding with vimdiff (also see set nofoldenable)

let g:netrw_liststyle=3                               | " Explore mode: 3 shows a complete tree instead of the current directory
let g:netrw_list_hide='^\..*'                         | " Explore mode: hide files starting with dot


" speed up CTRL-P Menu...
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
      \ --ignore .git
      \ --ignore .svn
      \ --ignore .hg
      \ --ignore .DS_Store
      \ --ignore "**/*.pyc"
      \ -g ""'

call vundle#end()             | " required by Vundle
filetype plugin indent on     | " required by Vundle
"================================================================================ 
" custom config
colorscheme mac_classic
" colorscheme coderonline
syntax enable

set noswapfile                | " noundofile, nobackup, nowritebackup
set backupdir=~/.vim/temp     | " using :set backup will copy current file to this directory
set directory=~/.vim/temp     | " 
set undodir=~/.vim/temp       | " 

set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth)
set autoindent                | " always set autoindenting on
set autochdir                 | " change to the current files working dir (might break some plugins!)
set copyindent                | " copy the previous indentation on autoindenting
set scrolloff=2               | " always keeps at least two lines visible (when seeking)
" set selectmode=mouse          | " avoid using select mode (only with mouse)
set mousemodel=popup_setpos   | " display a default right click menu for the selection (that is c&p is possible)
set selection=exclusive       | " includes last character of the selection into following command (like x or d)

set whichwrap=b,s,<,>,[,]     | " beyond beginning/end line causes cusor to wrap
set backspace=indent,eol,start| " allow backspacing over everything in insert mode, not needed with whichwrap
set diffopt+=vertical,iwhite,filler    | " lets diff ignore white spaces
set spell spelllang=en,de     | " enable spell checker
set virtualedit=onemore       | " one character beyond the line length should be navigatable (options: all,insert,block,onemore)
set breakindent cpoptions+=n  | " when wrapping lines indent wrapped line to align with the previews
set linebreak                 | " do not wrap in the middle of words
set display+=lastline         | " do not show the @ symbol in the end of a long line
set showcmd                   | " displays status line messages while selecting (matrix size)
set nofoldenable              | " do not fold code automatically
set tags+=~/.vim/systags      | " ctags -R -f ~/.vim/systags /usr/include /usr/local/include
set wildmenu wildmode=full    | " wildmenu code completion
set guifont="Droid Sans Mono for Powerline 10"

" search...
set ignorecase smartcase      | " if search pattern contains uppercase then search is case sensitive
set incsearch                 | " do incremental searching
set showmatch matchtime=4     | " blinks matching braces

set novisualbell              | " don't beep
set noerrorbells              | " don't beep
set clipboard=unnamedplus     | " makes copy and paste work (autoselectplus might work as well)
set number                    | " toggle line numbers
set formatprg=par             | " set external formatting program to par, use gwip to format with this
set laststatus=2              | " this is required for airline
set cmdheight=1               | " controls how many lines the command line has
set relativenumber            | " displays current lines line no as zero point from where relative numbers are getting counted
set timeoutlen=500            | " time between keys e.g. 80i=
set ttimeoutlen=10            | " set esc key timeout in ms 

set splitbelow                | " open new windows below the current one (i find that more intuitive)

if has("multi_byte")
  set encoding=utf-8          | " we need default utf-8 encoding to use cool chars as line break and so on (see below)
  scriptencoding utf-8        | " tell vim that we are using utf-8 here
  set showbreak+=| " symbol used in the beginning of a wrapped line
  set listchars=eol:| " symbols used when using :set list (which displays non-printable chars)
  set listchars+=trail:·      | " symbols used when using :set list (which displays non-printable chars)
  set listchars+=precedes:«   | " symbols used when using :set list (which displays non-printable chars)
  set listchars+=extends:»    | " symbols used when using :set list (which displays non-printable chars)
  set listchars+=tab:▸\       | " symbols used when using :set list (which displays non-printable chars)
endif

if has("autocmd")
  set modeline                | " set variables specific to a file, like indentation by adding a comment
  set modelines=3             | " how many lines in the beginning and end of the file can be mode lines?

  augroup resCur              | " make cursor appear in its previous position when reopening a file...
    autocmd BufReadPost * call setpos(".", getpos("'\""))
  augroup END

  augroup PreviewOnBottom     | " will open new windows below the current (only in insert mode, so that the preview window is drawn below)
    autocmd InsertEnter * set splitbelow
    autocmd InsertLeave * set splitbelow!
  augroup END

  augroup OmniFunc            | " this will enable omnicomplete just in case this configuration runs somewhere, where YouCompleteMe is not compiled
    if exists("+omnifunc")
      autocmd Filetype *
            \	if &omnifunc == "" |
            \	setlocal omnifunc=syntaxcomplete#Complete |
            \	setlocal completeopt=longest,menuone |
            \	endif
      autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
    endif
  augroup END

  autocmd FileType text setlocal textwidth=78  | " text files: set 'textwidth' to 78
  autocmd FileType gitcommit set tw=72         | " longer commit messages without auto line wrapping
  autocmd FileType LaTeX let g:tex_flavor = "latex"| set conceallevel=1| set concealcursor=
  autocmd BufNewFile,BufReadPost *.config set filetype=xml | " visual studio config file
  autocmd BufNewFile,BufReadPost *.csproj set filetype=xml | " visual studio project file
  autocmd BufNewFile,BufReadPost *.sln set filetype=xml    | " visual studio solution file
endif

"================================================================================ 
" gui stuff and appearance
if &t_Co > 2
  set hlsearch               | " highlight all search matches
  set cursorline             | " highlight currently selected line
endif


if has("gui_running")
  set mouse=a                   | " use mouse in gui-mode (which is default)
  set mouseshape+=n:beam,v:beam | " display a text input cursor even in normal and selection mode
  set guicursor=n-v-c:ver20-Cursor-blinkon500-blinkoff500  | " how the caret looks like
  set guitablabel=%t            | " do not display full path as tabname
  set guioptions+=m             | " menu bar
  set guioptions-=T             | " toolbar
  set guioptions+=r             | " right-hand scroll bar
  set guioptions-=c             | " use console dialogs instead of popups
  set guioptions+=a             | " autoselect: copy&paste using middleclick
  set guioptions+=e             | " add tab pages
  set guioptions+=p             | " use gui pointer callback for x11 
  set toolbariconsize=large     | " make the icon toolbar as big as possible
  "set columns=80               | " set initial window width (so that it fits the terminals)
else
  if &term =~? 'mlterm\|xterm\|screen'
    set t_Co=256                | " fixes incompatibilities with our color scheme
  endif
  set mouse=nh                  | " limits mouse usage to normal mode and help files, so that middle click text insertion works in insert mode
  set title                     | " set the terminal caption
  set icon                      | " sets the terminal icon to vim
  set ttyfast                   | " modern terminals are all fast in a way
  "set titleold="vim ended"      | " set terminal title after closing vim
  "set titlestring="VIM-CONSOLE" | " set window title
  "if has('mouse')
  "endif
endif


"================================================================================ 
" custom commands...
"
" assign selection keys (these i missed a lot)
nmap <S-Left> vh|                      " shift-left selects to the left
xmap <S-Left> h|                       " ^^
nmap <S-Right> vl|                     " shift-right selects to the right
xmap <S-Right> l|                      " ^^
nmap <S-Up> vk|                        " shift-up selects like other text editors
xmap <S-Up> k|                         " ^^
nmap <S-Down> vj|                      " shift down selects like other text editors
xmap <S-Down> j|                       " ^^
nmap <Home> ^|                         " default homing in code editors is the first letter of a line
xmap <Home> 0|                         " go to the beginning of the line
xmap <S-Home> 0|                       " ^^
xmap <Tab> >gv|                        " indent lines (and retain selection)
xmap <S-Tab> <gv|                      " unindent lines (and retain selection)
nmap <S-PageUp> VH|                    " selects predessing paragraph 
nmap <S-PageDown> VL|                  " selects following paragraph
nmap <C-S-PageUp> V{|                  " selects predessing paragraph 
nmap <C-S-PageDown> V}|                " selects following paragraph

nmap <C-o> :24vs.<CR>|                 " means the same as :vsplit. and opens the :Exlore -window with a width of 24





map <C-h> <C-w>h|map <C-j> <C-w>j|     " window navigation shortcuts
map <C-k> <C-w>k|map <C-l> <C-w>l|     " window navigation shortcuts

cmap w!! w !sudo tee % >/dev/null|     " write :w!! to execute :w as root user

" custom hotkeys... 
nnoremap <C-Tab> :tabnext<CR>|         " lets one use CTRL+Tab to switch between tabs
nnoremap <C-S-Tab> :tabprevious<CR>|   " use CTRL+Shift+Tab to switch to preview tab

nnoremap j gj|nnoremap k gk|           " do not jump over wrapped lines

nnoremap $ g$|                         " and make the $ key position the cursor after the last char of that line, not before
nnoremap <End> g$|                     " and make the <End> key position the cursor after the last char of that line
" function ExtendedHome()
"     let column = col('.')
"     normal! ^
"     if column == col('.')
"         normal! 0
"     endif
" endfunction
" noremap <silent> <Home> :call ExtendedHome()<CR>

nnoremap <C-z> u


"map <C-Right>        el
"map <C-left>         hgel
"vnoremap <C-S-Right> e
"vnoremap <C-S-left>  b


" plugin hotkeys
map <C-l> :TlistToggle<CR>|       " bind TagList to Hotkey Ctrl+L
inoremap <buffer> ( <C-X><C-o><C-p>(|  " when opening a bracket: call the OmniComplete function, display the menu, but deselect the first entry (C-p)


set makeprg=make\ test
nnoremap <F5> :!make<CR>|              " classic key binding: press F5 to compile and execute (if you have a Makefile with make test doing that)

"================================================================================
" deactivated on-demand commands (just in case one needs them one day)
"
" code completion: http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
" reacts on CTRL+P, CTRL+Space
"inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"inoremap <expr> <CR>       pumvisible() ? "\<C-y>" : "\<CR>"
"inoremap <expr> <Down>     pumvisible() ? "\<C-n>" : "\<Down>"
"inoremap <expr> <Up>       pumvisible() ? "\<C-p>" : "\<Up>"
"inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
"inoremap <expr> <PageUp>   pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
" set guiheadroom=0| " do not fill non-functional area of the empty editor with gtk background
" map shift-right to visually select and so on
"nnoremap <C-Right> El
"nnoremap <S-Right> vl
"nnoremap <S-Left> vj
"nnoremap <S-Up> vk
"nnoremap <S-Down> vj
" noremap % v% " jump between braces and highlight
"nnoremap <Home> ^
"vmap <Home> ^
"nnoremap <End> $
"vmap <End> $
"nnoremap <C-Tab> <C-PageDown>
"nnoremap <C-S-Tab> <C-PageUp>
":inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"inoremap <expr> <Esc>      pumvisible() ? "\<C-e>" : "\<Esc>" " breaks cursor keys!
" binding ESC can easily break cursor key movement on the console (tricky, because gvim works)
"inoremap <C-Space> <C-x><C-o>
"inoremap <C-@> <C-Space>
"
"map <Esc>OA k|map <Esc>OB j|map <Esc>OC l|map <Esc>OD h|             " allow cursor keys in insert mode
..