-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
163 lines (138 loc) · 6.62 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
161
162
163
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - set name of the terminal
" - set dark background and default syntax highlighting
" - highlight 81st column
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set term=xterm-256color
set background=dark
syntax on
highlight ColorColumn ctermbg=Black
set colorcolumn=81
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - show line numbers (to disable :set nonumber)
" - highlight current line number
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set number
set cursorline
set cursorlineopt=number
highlight LineNR cterm=none ctermbg=none ctermfg=DarkGrey
highlight CursorLineNR cterm=bold ctermbg=none ctermfg=White
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - use 4 spaces long tab character
" - insert 4 spaces in stead of tab character (to disable :set noexpandtab)
" - automatically indent new line based on the current line and file type
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
filetype plugin indent on
"set smartindent " works for c-like files (cannot be conbined with cindent)
"set cindent " more strict when it comes to syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - highlight the search text and seach while typing
" - do not wrap search around the end of file
" - enable case insensitive search by default, eg: /text or /Text\c
" - for case sensitive search use: /Text or /text\C
" - highlight search text in yellow and text to be replaced in red
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set hlsearch
set incsearch
set nowrapscan
set ignorecase
set smartcase
highlight Search ctermfg=black ctermbg=yellow
highlight IncSearch ctermfg=red ctermbg=white
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - highlight trailing whitespaces and tabs
" - show tab character and whitespace character
" - delete all trailing whitespaces by pressing Shift+x or X
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"highlight ExtraWhitespace ctermbg=Black ctermfg=DarkGrey
"match ExtraWhitespace /\s\+$\|\t/
function! ShowSpacesAndTabs()
highlight TabCharacter ctermbg=Black ctermfg=DarkGrey
highlight ExtraWhitespace ctermbg=Black ctermfg=Red
call matchadd('TabCharacter', '\t', 1)
call matchadd('ExtraWhitespace', '\s\+$', 2)
endfun
autocmd BufEnter * :call ShowSpacesAndTabs()
autocmd WinNew * :call ShowSpacesAndTabs()
autocmd TabNew * :call ShowSpacesAndTabs()
set listchars=tab:›\ ,trail:.
set list
map X :%s/\s\+$//g <CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - open vertical split on the right and horizontal split below the current
" - use Ctrl+W+W or Ctrl+M (or simply 'Enter') to navigate between splits
" - highlight status line of current split
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set splitright
set splitbelow
map <C-m> <C-W>w
"map <C-n> <C-W>w
"map <C-b> <C-W>W
highlight StatusLine ctermbg=black ctermfg=gray
highlight StatusLineNC ctermbg=black ctermfg=darkgray
highlight VertSplit ctermbg=gray ctermfg=gray
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - keep 5 lines above and below the cursor while vertical scrolling
" - disable text wrap (to enable :set wrap)
" - scroll 1 column at a time and keep 10 columns before and after cursor
" while horizontal scrolling
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set scrolloff=5
set nowrap
set sidescroll=1
set sidescrolloff=10
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - enable moving of a cursor beyod end of the line in visual block mode
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"set virtualedit=block,insert
set virtualedit=block
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - configure color highlights for vimdiff
" - highlight TODOs in red
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
highlight DiffAdd ctermfg=black ctermbg=LightGreen
highlight DiffDelete ctermfg=black ctermbg=LightRed
highlight DiffChange ctermfg=black ctermbg=LightBlue
highlight DiffText ctermfg=black ctermbg=Blue
highlight Todo ctermfg=Red ctermbg=Black
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - show function name on the second status line based on the cursor position
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ShowFuncName()
let l:linenum = line(".")
if !exists('w:linenum') || w:linenum != l:linenum
let w:linenum = l:linenum
let l:funcname = getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bcWn'))
if l:funcname != ""
echo ">>>" strpart(l:funcname, 0, winwidth(0)-24)
else
echo ""
endif
endif
endfun
set laststatus=2
set updatetime=10 " wait for 10ms before CursorHold autocmd event
autocmd CursorHold * :call ShowFuncName()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - jump to a tag if there is only one matching tag otherwise display a list
" of matching tags by pressing Ctrl+]
" - display contents of tag stack by pressing Shift+t or T
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <C-]> g<C-]>
map T :tags <CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - jump to the last position when reopening a file
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" - create a backup of the intermediate states of a file, only if '.backup'
" directory is present in PWD
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if isdirectory(".backup")
au BufReadPre * silent !cp % .backup/$(date +\%y\%m\%d\%H\%M\%S)\-o$(echo %:p | sed 's/\//\-/g')
au BufWritePost * silent !cp % .backup/$(date +\%y\%m\%d\%H\%M\%S)\-w$(echo %:p | sed 's/\//\-/g')
endif