-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.vimrc
472 lines (340 loc) · 11.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
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" __ ___ _ _
" /\ \ \___ / _ \ |_ _ __ _(_)_ __ ___
" / \/ / _ \ / /_)/ | | | |/ _` | | '_ \/ __|
" / /\ / (_) | / ___/| | |_| | (_| | | | | \__ \
" \_\ \/ \___/ \/ |_|\__,_|\__, |_|_| |_|___/
" |___/
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"------------------SETTINGS------------------
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Disable the vim bell
set visualbell
" Disable auto commenting in a new line
autocmd Filetype * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Setting the character encoding of Vim to UTF-8
set encoding=UTF-8
" Enable type file detection. Vim will be able to try to detect the type of file is use.
filetype on
" Enable spell check
set spell
" Smart tab
set smarttab
" Search down to subfolders
set path+=**
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
filetype indent on
" Turn syntax highlighting on.
syntax on
" Add numbers to the file.
set number relativenumber
" Mouse functionality
set mouse=a
" Color scheme
colorscheme slate
" Highlight cursor line underneath the cursor horizontally.
set cursorline
" Highlight cursor line underneath the cursor vertically.
set cursorcolumn
" Set shift width to 4 spaces.Set tab width to 4 columns.
set shiftwidth=4
set tabstop=4
" If the current file type is HTML, set indentation to 2 spaces.
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 expandtab
" Do not save backup files.
set nobackup
" Do wrap lines.
set wrap
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
set hlsearch
" Ignore capital letters during search.
set ignorecase
" Show partial command you type in the last line of the screen.
set showcmd
" Show the mode you are on the last line.
set showmode
" Show matching words during a search.
set showmatch
" Set the commands to save in history default number is 20.
set history=1000
" Setting the split window to open as i like (like in a WM - qtile)
set splitbelow splitright
" Enable auto completion menu after pressing TAB.
set wildmenu
" There are certain files that we would never want to edit with Vim.
" Wild menu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" If Vim version is equal to or greater than 7.3 enable undo file.
" This allows you to undo changes to a file even after saving it.
if version >= 703
set undodir=~/.vim/backup
set undofile
set undoreload=10000
endif
" File Browsing settings
let g:netrw_banner=0
let g:netrw_liststyle=3
let g:netrw_showhide=1
let g:netrw_winsize=20
" Auto Completion - Enable Omni complete features
set omnifunc=syntaxcomplete#Complete
" Enable Spelling Suggestions for Auto-Completion:
set complete+=k
set completeopt=menu,menuone,noinsert
" Minimalist-Tab Complete
inoremap <expr> <Tab> TabComplete()
fun! TabComplete()
if getline('.')[col('.') - 2] =~ '\K' || pumvisible()
return "\<C-N>"
else
return "\<Tab>"
endif
endfun
" Minimalist-Autocomplete
inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
autocmd InsertCharPre * call AutoComplete()
fun! AutoComplete()
if v:char =~ '\K'
\ && getline('.')[col('.') - 4] !~ '\K'
\ && getline('.')[col('.') - 3] =~ '\K'
\ && getline('.')[col('.') - 2] =~ '\K' " last char
\ && getline('.')[col('.') - 1] !~ '\K'
call feedkeys("\<C-N>", 'n')
end
endfun
" Closing compaction in insert mode
inoremap [ []<left>
inoremap ( ()<left>
inoremap { {}<left>
inoremap /* /**/<left><left>
"------------------GVIM - GUI VERSION------------------
if has('gui_running')
" Set the color scheme.
color slate
" Font
if has("macvim")
set guifont=Menlo\ Regular:h14
elseif has("win32")
set guifont="Consolas 14"
else
set guifont=Consolas\ 18
endif
" Hide the toolbar.
set guioptions-=T
" Hide the right-side scroll bar.
set guioptions-=r
" Start Lex Tree and put the cursor back in the other window.
autocmd VimEnter * :Lexplore | wincmd p
endif
"------------------Hex_Toggle_Functions------------------
function! DoHex()
" Get the current buffer name
let current_file = expand('%')
" New file name
let new_file = current_file . '.hex'
" Save the current buffer as a hex file
execute 'w !xxd > ' . new_file
echo "Hex file created and saved as " . new_file
endfunction
function! UndoHex()
" Get the current buffer name
let current_file = expand('%')
" Name stage 1: Remove the .hex extension if it exists
let new_file_stage1 = substitute(current_file, '\.hex$', '', '')
" Get the file name without extension
let file_name = substitute(new_file_stage1, '\(.*\)\.\(\w\+\)$', '\1', '')
" Get the file extension
let file_extension = substitute(new_file_stage1, '\(.*\)\.\(\w\+\)$', '\2', '')
" Add 'M' before the extension(M = Modded)
let new_file = file_name . 'M.' . file_extension
" Save the current buffer as a reversed hex file
execute 'w !xxd -r > ' . new_file
echo "Reversed Hex file created and saved as " . new_file
endfunction
" Function to toggle between hex and original states
function! HexState()
" Get user input to choose the operation (0 for DoHex, 1 for UndoHex)
let operation = input("Choose operation (0 for DoHex, 1 for UndoHex): ")
if operation == 0
" Execute the DoHex function
call DoHex()
elseif operation == 1
" Execute the UndoHex function
call UndoHex()
else
echo "Invalid choice. Aborting."
endif
endfunction
"------------------Hebrew_Toggle_Function------------------
function! ToggleHebrew()
if &rl
set norl
set keymap=
set spell
echom "Hebrew mode OFF"
else
set rl
set keymap=hebrew
set nospell
echom "Hebrew mod ON"
endif
endfunction
"------------------STATUS_LINE------------------
" Status line
set laststatus=2
set statusline=
set statusline+=%2*
set statusline+=%{StatuslineMode()}
set statusline+=\
set statusline+=%{SpellCheckStatus()}
set statusline+=%1*
set statusline+=\
set statusline+=%3*
set statusline+=<
set statusline+=-
set statusline+=\
set statusline+=%f
set statusline+=\
set statusline+=-
set statusline+=>
set statusline+=\
set statusline+=%4*
set statusline+=%m
set statusline+=%=
set statusline+=%h
set statusline+=%r
set statusline+=%4*
set statusline+=%c
set statusline+=/
set statusline+=%l
set statusline+=/
set statusline+=%L
set statusline+=\
set statusline+=%1*
set statusline+=|
set statusline+=%y
set statusline+=\
set statusline+=%4*
set statusline+=%P
set statusline+=\
set statusline+=%3*
set statusline+=t:
set statusline+=%n
set statusline+=\
" Colors
hi User2 ctermbg=lightgreen ctermfg=black guibg=lightgreen guifg=black
hi User1 ctermbg=brown ctermfg=white guibg=black guifg=white
hi User3 ctermbg=brown ctermfg=lightcyan guibg=black guifg=lightblue
hi User4 ctermbg=brown ctermfg=green guibg=black guifg=lightgreen
" Mode
function! StatuslineMode()
let l:mode=mode()
if l:mode==#"n"
return "NORMAL"
elseif l:mode==#"V"
return "VISUAL LINE"
elseif l:mode==?"v"
return "VISUAL"
elseif l:mode==#"i"
return "INSERT"
elseif l:mode ==# "\<C-V>"
return "V-BLOCK"
elseif l:mode==#"R"
return "REPLACE"
elseif l:mode==?"s"
return "SELECT"
elseif l:mode==#"t"
return "TERMINAL"
elseif l:mode==#"c"
return "COMMAND"
elseif l:mode==#"!"
return "SHELL"
else
return "VIM"
endif
endfunction
" Spell Check Status
function! SpellCheckStatus()
if &spell
return " [SPELL]"
else
return ''
endif
endfunction
"------------------KEY_BINDINGS------------------
" Spell-check on\off
map <C-z> :setlocal spell! spelllang=en_us<CR>
" Type jj to exit insert mode quickly.
inoremap jj <Esc>
" Format a paragraph into lines
map Q gq<CR>
" Set the space as the leader key.
let mapleader = " "
" Select all the text
nnoremap <leader>a ggVG
" Opening a file explore
map <leader>e :Lex<CR>
" Opening a file from explorer
map <leader>o :Explore<CR>
" Opening a terminal window
map <c-t> :ter<CR>
" Closing the terminal window
tnoremap <c-t> exit<CR>
" CTRL+I OR Esc to make the terminal scrollable and I to input mode
tnoremap <c-i> <c-w><s-n>
tnoremap <Esc> <C-\><C-n>
" You can split the window in Vim. y - in the y access , x - in the x access
map <leader>y :split<space>
map <leader>x :vsplit<space>
" Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l.
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Resize split windows using arrow keys by pressing:
" CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT.
noremap <a-up> <c-w>+
noremap <a-down> <c-w>-
noremap <a-left> <c-w>>
noremap <a-right> <c-w><
" Moving between tabs
map <leader>t gt
" Opening\Creating a file in a new tab - write the tab to open
nnoremap <leader>c :tabedit<space>
" Saving a file using CTRL+S
map <C-S> :w<CR>
" Quitting and saving a file using CTRL+S
map <C-q> :wq<CR>
" Surround word with a wanted character
nnoremap <leader>sw <cmd>echo "Press a character: " \| let c = nr2char(getchar()) \| exec "normal viwo\ei" . c . "\eea" . c . "\e" \| redraw<CR>
" Replace all occurrences of a word
nnoremap <leader>rw :%s/\<<c-r><c-w>\>//g<left><left>
" Toggle Hebrew key maps and Right-to-Left setting
nnoremap <leader>ht <cmd>call ToggleHebrew()<CR>
" Toggle between creating a Hex conversion file and reversing the conversion
nnoremap <leader>hx <cmd>call HexState()<CR>
" Map V-Block to not confuse with Past
noremap <leader>v <C-v>
" For copy and past
map <C-V> "+P
vnoremap <C-C> "*y :let @+=@*<CR>
" If not in Linux replace the keybinding in above line with: vnoremap <C-C> "+y
" Seeing the registers
nnoremap <leader>r <cmd>registers<CR>
" Moving lines in visual mode
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '>-2<CR>gv=gv
"------------------END_KEY------------------