Last active
October 13, 2020 03:39
-
-
Save airstrike/e361d94dbe4bb90f4fe6ff4418b45cfd to your computer and use it in GitHub Desktop.
Latest vimrc file (2019)
This file contains hidden or 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
" VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set so=2 " Show at least 2 lines around cursors when moving vertically | |
set ruler "Always show current position | |
set cmdheight=1 "The commandbar height | |
" Set backspace config | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" tab, spacing, wrapping | |
set expandtab | |
set shiftwidth=4 | |
set tabstop=4 | |
set smarttab | |
set ai | |
set si | |
set nowrap | |
set autoread | |
set ignorecase "Ignore case when searching | |
set smartcase | |
set hlsearch "Highlight search things | |
set incsearch "Make search act like search in modern browsers | |
set nolazyredraw "Don't redraw while executing macros | |
set magic "Set magic on, for regular expressions | |
set showmatch "Show matching bracets when text indicator is over them | |
set mat=2 "How many tenths of a second to blink | |
" No sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set encoding=utf8 | |
try | |
lang en_US | |
catch | |
endtry | |
set ffs=unix,dos,mac "Default file types | |
" General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Sets how many lines of history VIM has to remember | |
set history=700 | |
" Enable filetype plugin | |
filetype plugin on | |
filetype indent on | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Fast saving | |
nnoremap <leader>w :w!<cr> | |
" Close buffer | |
nnoremap <leader>q :bdelete<cr> | |
" Fast buffer switching | |
nnoremap <leader>, :bprev<cr> | |
nnoremap <leader>. :bnext<cr> | |
" Fast editing of the .vimrc | |
nnoremap <leader>e :e! ~/.vimrc<cr> | |
" When vimrc is edited, reload it | |
autocmd! bufwritepost .vimrc source ~/.vimrc | |
" key mappings | |
" nnoremap <silent> <ESC> :noh<CR><ESC> | |
" smarter moving around | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" Statusline | |
"""""""""""""""""""""""""""""" | |
" Always hide the statusline | |
set laststatus=1 | |
" Format the statusline | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
else | |
return '' | |
endif | |
endfunction | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
noremap <Leader>t :%s/\t/ /ge<cr> | |
" Remove any trailing whitespace that is in the file | |
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | |
" Restore cursor position to where it was before | |
augroup JumpCursorOnEdit | |
au! | |
autocmd BufReadPost * | |
\ if expand("<afile>:p:h") !=? $TEMP | | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ let JumpCursorOnEdit_foo = line("'\"") | | |
\ let b:doopenfold = 1 | | |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
\ let b:doopenfold = 2 | | |
\ endif | | |
\ exe JumpCursorOnEdit_foo | | |
\ endif | | |
\ endif | |
" Need to postpone using "zv" until after reading the modelines. | |
autocmd BufWinEnter * | |
\ if exists("b:doopenfold") | | |
\ exe "normal zv" | | |
\ if(b:doopenfold > 1) | | |
\ exe "+".1 | | |
\ endif | | |
\ unlet b:doopenfold | | |
\ endif | |
augroup END | |
" Misc Settings | |
" Necesary for lots of cool vim things | |
set nocompatible | |
" This shows what you are typing as a command. I love this! | |
set showcmd | |
" Folding Stuffs | |
set foldmethod=marker | |
" Needed for Syntax Highlighting and stuff | |
filetype on | |
filetype plugin on | |
syntax enable | |
set grepprg=grep\ -nH\ $* | |
" Cool tab completion stuff | |
set wildmenu | |
set wildmode=list:longest,full | |
" Line Numbers PWN! | |
set number | |
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! | |
inoremap jj <Esc> | |
nnoremap JJJJ <Nop> | |
" Incremental searching is sexy | |
" set incsearch | |
"{{{ Paste Toggle | |
let paste_mode = 0 " 0 = normal, 1 = paste | |
func! Paste_on_off() | |
if g:paste_mode == 0 | |
set paste | |
let g:paste_mode = 1 | |
echo "Paste ON" | |
else | |
set nopaste | |
let g:paste_mode = 0 | |
echo "Paste OFF" | |
endif | |
return | |
endfunc | |
"}}} | |
nnoremap <Leader>p :call Paste_on_off()<CR> | |
" Up and down are more logical with g.. | |
nnoremap <silent> k gk | |
nnoremap <silent> j gj | |
inoremap <silent> <Up> <Esc>gka | |
inoremap <silent> <Down> <Esc>gja | |
" Create Blank Newlines and stay in Normal mode | |
nnoremap <silent> zj o<Esc> | |
nnoremap <silent> zk O<Esc> | |
" Space will toggle folds! | |
nnoremap <space> za | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
map N Nzz | |
map n nzz | |
" Testing | |
set completeopt=longest,menuone,preview | |
" Swap ; and : Convenient. | |
nnoremap ; : | |
nnoremap : ; | |
" removing selectmode | |
set selectmode= | |
colorscheme default | |
set background=light | |
" easier copy/paste into system clipboard | |
set mouse= " to enable right-click paste | |
noremap <Leader>y "*y | |
noremap <Leader>p "*p | |
noremap <Leader>Y "+y | |
noremap <Leader>P "+p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment