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
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
  filetype plugin indent on
endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd		" Show (partial) command in status line.
"set ignorecase		" Do case insensitive matching
"set smartcase		" Do smart case matching
"set incsearch		" Incremental search
"set hidden             " Hide buffers when they are abandoned
"set mouse=a		" Enable mouse usage (all modes)

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

"Source vim each time I save it.
if has("autocmd")
  autocmd bufwritepost .vimrc source $MYVIMRC
 endif


function! SplitColors()
    if winnr("$") > 1 
        if &ft == 'python'
            colo badwolf
        else
            colo molokai
        endif
    endif
endfunction

"Change colorscheme acc. to filetype when switching tabs.
function! ChangeColors()
    if &ft == 'python'
        colo badwolf
    else
        colo molokai
    endif
endfunction


"Prevent behaviour of <CR>
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>

autocmd BufEnter * call SplitColors()

"Call ChangeColors()
autocmd TabEnter * call ChangeColors()

autocmd! BufNewFile * silent! 0r /home/Noob/.vim/skel/bashscript.%:e
autocmd! BufNewFile * silent! 0r /home/Noob/.vim/skel/pythonscript.%:e
autocmd! BufNewFile * silent! 0r /home/Noob/.vim/skel/javacode.%:e
autocmd BufEnter,BufNewFile *.py colo badwolf
autocmd BufLeave *.py colo badwolf

autocmd BufWrite,BufRead *.java,*.vala :normal gg=G

autocmd BufRead *.vala,*.vapi set efm=%f:%l.%c-%[%^:]%#":\ %t%[%^:]%#":\ %m
au BufRead,BufNewFile *.vala,*.vapi setfiletype vala

let vala_comment_strings = 1

au FocusLost * :wa
call pathogen#infect()
call pathogen#helptags()
"colorscheme twilight256
colorscheme molokai
"set background=dark
filetype plugin indent on
filetype plugin on


"----------------------------------VIM GLOBAL SETTINGS-----------------------------------------------


set nocompatible
set nu
set encoding=utf-8
set autoindent shiftwidth=4
set t_Co=256
set smarttab
set backup
set expandtab
set smartindent
set autowrite		" Automatically save before commands like :next and :make
set tabstop=4
set showmatch		" Show matching brackets.
"set smartcase
set incsearch 
set hlsearch
set textwidth=90
set backupdir=/home/Noob/VimTemp/backup
set undodir=/home/Noob/VimTemp/undohist
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
set laststatus=2
set modifiable


"---------------VIM STATUSLINE----------------------------------------------------------------------


"Powerline configuration
let g:Powerline_symbols='fancy'
let g:Powerline_colorscheme='skwp'


"----------------VIM MAPPING----------------------------------------------------------------------------


"Prevent vim to send #comment to column 0 in python.
inoremap # X<BS>#

"Search highlighted cleared
nnoremap //  :nohlsearch<CR>

"Toggle Tagbar plugin
nnoremap <F8> :TagbarToggle<CR> 

"Mapping for Pydoc plugin
cnoremap py :Pydoc

"Create newline below the current line
nnoremap <CR> o<Esc>

"Replace test with filename for .java files
nnoremap <F2> :%s/test/\=expand('%:r')/g<CR>

"Use tab to move b/w split panes
nnoremap <tab><tab> <C-w>w

"Open a new buffer(quickfix_list) with copen to see occurrences of
"highlighted word.
nnoremap <silent> ,/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>

"Tenplate to replace highlighted text.
cnoremap re %s//

"Convert word to uppercase in insert mode.
inoremap <C-u> <Esc>g<S-u>wi

"Convert word to uppercase in normal mode.
nnoremap <C-u> g<S-u>w

"Edit vimrc
nnoremap ,e :vsplit $MYVIMRC<cr>

"Source vimrc
nnoremap ,s :source $MYVIMRC<cr>

"Fix typo while using :wq
cnoremap Wq wq

"Fix typo while using :q
cnoremap Q q