-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
160 lines (131 loc) · 5.1 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
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Elixir Support
Plugin 'elixir-lang/vim-elixir'
" GO Support
Plugin 'fatih/vim-go'
" Ctrlp for awesome file search
Plugin 'ctrlpvim/ctrlp.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
" "filetype plugin on
" "
" " Brief help
" " :PluginList - lists configured plugins
" " :PluginInstall - installs plugins; append `!` to update or just
" :PluginUpdate
" " :PluginSearch foo - searches for foo; append `!` to refresh local cache
" " :PluginClean - confirms removal of unused plugins; append `!` to
" auto-approve removal
" "
" " see :h vundle for more details or wiki for FAQ
" " Put your non-Plugin stuff after this line
" It is important ot have utf-8 as encoding, right?
set encoding=utf-8
" Now, something really important as well, autoidentation!
set autoindent
" It is good to know where you are in the file, right? Let's to it!
set ruler
" First, let us enable absolute line numbers
set number
" Relative line numbers
set relativenumber
" Let us have a function to alternate between relative and absolute numbering
function! NumberToggle()
set relativenumber!
endfunc
" Ctrl+n is our mapping for this function!
nnoremap <C-n> :call NumberToggle()<cr>
autocmd FocusLost * :set norelativenumber
autocmd FocusGained * :set relativenumber
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
" Sets the title of the terminal as the name of the file
set title
" Highlight the search cases
set hlsearch
" Syntax highlighting
syntax on
" What if vim can access the system clipboard? Great!
set clipboard=unnamed
"set clipboard=unnmaedplus
" Set folding based on indentation
set foldmethod=indent
autocmd Syntax * normal zR
" Just for safety, let us deactivate the arrows, ok? ;)
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
vnoremap <Left> :echoe "Use h"<CR>
vnoremap <Right> :echoe "Use l"<CR>
vnoremap <Up> :echoe "Use k"<CR>
vnoremap <Down> :echoe "Use j"<CR>
inoremap <Left> <Esc>:echoe "Use h"<CR>i
inoremap <Right> <Esc>:echoe "Use l"<CR>i
inoremap <Up> <Esc>:echoe "Use k"<CR>i
inoremap <Down> <Esc>:echoe "Use j"<CR>i
" Let's toggle the insert mode with ctrl+space
nnoremap <C-space> i
imap <C-space> <Esc>
set wildmenu
set showcmd
set backspace=indent,eol,start
hi Search cterm=NONE ctermfg=white ctermbg=gray
" No backup files
set nobackup
" Only in case you don't want a backup file while editing
set nowritebackup
" No swap files
set noswapfile
" The key C will open the selected text at visual mode in a bash, so it will be
" possible to copy it without copying the line numbers etc. ;)
vnoremap C :w ! bash -c cat<CR>
" Open some files in its respective reader
" It delegates to `open`, which is a command on OS X. For GNU/Linux, better to
" use xdg-open
augroup nonvim
au!
au BufRead *.png,*.jpg,*.pdf,*.gif,*.xls*,*.ppt*,*.doc*,*.rtf sil exe "!open " . shellescape(expand("%:p")) | bd | let &ft=&ft
augroup end
" The width of a TAB is set to 4. Still it is a \t. It is just that Vim will
" interpret it to be having a width of 4.
set tabstop=4
" Indents will have a width of 4
set shiftwidth=4
" A combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop. Sets the number of columns for a TAB
set softtabstop=4
" Expand TABs to spaces
set expandtab
" Make TAB insert indents instead of tabs at the beginning of a line
set smarttab
" Commenting blocks of code.
autocmd FileType c,cpp,java,scala let b:comment_leader = '// '
autocmd FileType sh,ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
" Changing tab behavior
autocmd FileType elixir setlocal shiftwidth=2 tabstop=2
" Turns off the highlighting of the current search result by hitting return
nnoremap <CR> :noh<CR><CR>
" Removes trailing whitespaces
autocmd FileType py autocmd BufWritePre <buffer> %s/\s\+$//e
" Automatically reloads vimrc when updating it from within vim
augroup vimrc " Source vim configuration upon save
autocmd! BufWritePost $MYVIMRC source % | echom "Reloaded " . $MYVIMRC | redraw
autocmd! BufWritePost $MYGVIMRC if has('gui_running') | so % | echom "Reloaded " . $MYGVIMRC | endif | redraw
augroup END