Last active
January 10, 2024 11:33
-
-
Save riicchhaarrd/4b910f906cdc63ce50e5373409fbd14c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colorscheme onehalflight | |
"colorscheme gruvbox | |
"set background=dark | |
" Disable bell | |
set visualbell | |
set t_vb= | |
set t_u7= | |
set tabstop=4 | |
set shiftwidth=4 smarttab | |
set autoindent | |
filetype plugin on | |
syntax on | |
set number | |
set mouse=a | |
set nopaste | |
" https://unix.stackexchange.com/questions/93144/exit-vim-more-quickly | |
inoremap <C-q> <esc> | |
vnoremap <C-q> <esc> | |
nnoremap <C-q> :q<cr> | |
" https://superuser.com/questions/1056929/open-file-in-vertical-split-in-vim-netrw/1062063 | |
let g:netrw_altv=1 | |
" https://shapeshed.com/vim-netrw/ | |
let g:netrw_banner = 0 | |
let g:netrw_liststyle = 3 | |
let g:netrw_browse_split = 4 | |
"let g:netrw_altv = 1 | |
let g:netrw_winsize = 25 | |
augroup ProjectDrawer | |
autocmd! | |
" https://stackoverflow.com/questions/72104299/how-to-make-netrw-explorer-appears-automatically-on-the-left-side-when-opening-a | |
"autocmd TabNew * :Vexplore | |
autocmd VimEnter * :Vexplore | |
augroup END | |
" A vertical split is used. (for horizontal splitting, see netrw-o) Normally, the v key splits the window vertically with the new window and cursor at the left. Just press t instead of pressing Enter for a new tab, or v for a new vertical split. In Vim, tabs contain splits. | |
" https://gist.github.com/Starefossen/5957088 | |
" https://www.reddit.com/r/neovim/comments/jr5zdb/remapping_keys_in_netrw/ | |
augroup netrw_mapping | |
autocmd! | |
autocmd filetype netrw call NetrwMapping() | |
augroup END | |
function! NetrwMapping() | |
nmap <buffer> <right> <CR> | |
nmap <buffer> <left> <CR> | |
nmap <buffer> <Tab> <CR> | |
"nmap <buffer> <space> <CR> | |
" Uncomment when using default netrw | |
"nmap <buffer> <left> -<esc> | |
endfunction | |
" https://superuser.com/questions/410982/in-vim-how-can-i-quickly-switch-between-tabs | |
noremap <leader>1 1gt | |
noremap <leader>2 2gt | |
noremap <leader>3 3gt | |
noremap <leader>4 4gt | |
noremap <leader>5 5gt | |
noremap <leader>6 6gt | |
noremap <leader>7 7gt | |
noremap <leader>8 8gt | |
noremap <leader>9 9gt | |
noremap <leader>0 :tablast<cr> | |
"noremap <space><left> <C-w><left> | |
"noremap <space><right> <C-w><right> | |
"noremap <space><up> gT | |
"noremap <space><down> gt | |
"noremap <Tab> <C-w>w | |
"map <C-up> <C-w><up> | |
"map <C-down> <C-w><down> | |
"map <C-left> <C-w><left> | |
"map <C-right> <C-w><right> | |
map <expr><silent> <C-left> tabpagenr('$') > 1 ? 'gT' : '<C-w><left>' | |
map <expr><silent> <C-right> tabpagenr('$') > 1 ? 'gt' : '<C-w><right>' | |
"map <C-left> gT | |
"map <C-right> gt | |
" :Vex open netrw in split | |
" netrw t = open in new tab, v = open in split | |
nnoremap a i | |
nnoremap i a | |
set timeoutlen=1000 | |
set ttimeoutlen=0 | |
noremap <silent> <C-S> :update<CR> | |
vnoremap <silent> <C-S> <C-C>:update<CR> | |
inoremap <silent> <C-S> <C-O>:update<CR> | |
noremap <C-f> / | |
noremap <CR> n | |
noremap <backspace> d | |
inoremap <C-f> <C-o>/ | |
" https://vim.fandom.com/wiki/Format_pasted_text_automatically | |
nnoremap p p=`] | |
set whichwrap+=<,>,[,] | |
" https://vi.stackexchange.com/questions/202/scroll-the-screen-not-the-cursor-when-using-scrollwheel | |
"nmap <Down> <C-e> | |
"nmap <Up> <C-y> | |
"nnoremap <LeftMouse> i | |
"inoremap <RightMouse> <C-c>pi | |
"vnoremap <RightMouse> y<C-c> | |
"nnoremap <RightMouse> p | |
" https://stackoverflow.com/questions/4766230/map-shift-tab-in-vim-to-inverse-tab-in-vim | |
" for command mode | |
nnoremap <S-Tab> << | |
nnoremap <Tab> >> | |
" for insert mode | |
inoremap <S-Tab> <C-d> | |
vnoremap <S-Tab> <gv | |
vnoremap <Tab> >gv | |
xnoremap <S-Tab> <gv | |
xnoremap <Tab> >gv | |
snoremap <Tab> <C-o>>gv<C-g> | |
snoremap <S-Tab> <C-o><gv<C-g> | |
inoremap <c-y> <c-o>:redo<CR> | |
vnoremap <c-y> <c-c>:redo<CR>gv | |
nnoremap <c-y> :redo<CR> | |
" https://stackoverflow.com/questions/12436154/how-to-go-back-ctrlz-in-vi-vim | |
"inoremap <c-z> <c-o>:u<CR> | |
vnoremap <c-z> <c-c>:u<CR>gv | |
nnoremap <c-z> :u<CR> " Avoid using this** | |
" vnoremap <C-c> y<C-c>i | |
" `] goto end of pasted text | |
" inoremap <C-v> <C-c>p`]a | |
" https://stackoverflow.com/questions/9721732/mapping-shift-arrows-to-selecting-characters-lines | |
" nmap <S-Up> v<Up> | |
" nmap <S-Down> v<Down> | |
" nmap <S-Left> v<Left> | |
" nmap <S-Right> v<Right> | |
" vmap <S-Up> <Up> | |
" vmap <S-Down> <Down> | |
" vmap <S-Left> <Left> | |
" vmap <S-Right> <Right> | |
" imap <S-Up> <Esc>v<Up> | |
" imap <S-Down> <Esc>v<Down> | |
" imap <S-Left> <Esc>v<Left> | |
" imap <S-Right> <Esc>v<Right> | |
vmap <C-c> y<Esc>i | |
vmap <C-x> d<Esc>i | |
"map <C-v> pi | |
imap <C-v> <Esc>p`]i | |
imap <C-z> <Esc>u | |
nnoremap <C-v> p`]i | |
nnoremap <space> i | |
inoremap <C-o> <Esc>:e | |
nnoremap <C-o> :e | |
inoremap <C-d> <Esc>yypi | |
nnoremap <C-d> yypi | |
nnoremap <C-a> ggVG | |
inoremap <C-a> <Esc>ggVG | |
vnoremap <C-a> <Nop> | |
vnoremap <Right> <Esc>G | |
vnoremap <Left> <Esc>gg | |
vnoremap <backspace> di | |
" for reg in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'] | |
"for reg in ['a','b','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'] | |
" execute 'vnoremap ' .. reg .. ' d<Esc>i' .. reg .. '' | |
"endfor | |
vnoremap <space> d<Esc>i<space> | |
vnoremap <cr> d<Esc>i<cr> | |
set keymodel=startsel,stopsel | |
" https://stackoverflow.com/questions/80677/what-is-the-difference-between-c-c-and-c-in-vim | |
inoremap <C-c> <Esc><Esc> | |
" WSL yank support | |
let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point | |
if executable(s:clip) | |
augroup WSLYank | |
autocmd! | |
autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif | |
augroup END | |
endif | |
" https://vi.stackexchange.com/questions/29129/how-do-i-make-the-cursor-blink | |
augroup cursor_behaviour | |
autocmd! | |
" reset cursor on start: | |
autocmd VimEnter * silent !echo -ne "\e[2 q" | |
" cursor blinking bar on insert mode | |
let &t_SI = "\e[5 q" | |
" cursor steady block on command mode | |
let &t_EI = "\e[2 q" | |
" highlight current line when in insert mode | |
autocmd InsertEnter * set cursorline | |
" turn off current line highlighting when leaving insert mode | |
autocmd InsertLeave * set nocursorline | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment