Last active
October 31, 2018 22:08
-
-
Save seanpianka/7a73c5c98e62a9f5d2014df4cd568f3b to your computer and use it in GitHub Desktop.
quickstart vim
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
set term=xterm-256color | |
map <space> viw | |
" Swap to the left-adjacent vim tab | |
nnoremap <left> gT | |
" Swap to the right-adjacent vim tab | |
nnoremap <right> gt | |
" escape should be easier to get to | |
inoremap jj <ESC> | |
" Disables cursor movement with arrow keys | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> | |
" disabling that help button | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
"Always show current position | |
set relativenumber | |
set number | |
" Configure backspace so wraps to the previous line | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" Add a bit extra margin to the left | |
set foldcolumn=1 | |
" Enable syntax highlighting | |
syntax enable | |
set background=dark | |
set t_Co=256 | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
" The "//" at the end of the directory means that file names | |
" will be built from the complete path to the file with all | |
" path separators substituted to percent "%" sign. This will | |
" ensure file name uniqueness in the preserve directory. | |
set noswapfile | |
if !isdirectory($HOME."/.vim") | |
silent! execute "!mkdir ~/.vim" | |
endif | |
if !isdirectory($HOME."/.vim/backupdir") | |
silent! execute "!mkdir ~/.vim/backupdir" | |
endif | |
set backupdir=~/.vim/backupdir//,. | |
set backup | |
if !isdirectory($HOME."/.vim/undodir") | |
silent! execute "!mkdir ~/.vim/undodir" | |
endif | |
set undodir=~/.vim/undodir//,. | |
set undofile | |
if !isdirectory($HOME."/.vim/tmpdir") | |
silent! execute "!mkdir ~/.vim/tmpdir" | |
endif | |
set directory=~/.vim/tmpdir//,. | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 4 spaces | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 | |
" Linebreak on 50000 characters | |
" Essentially not enforcing linebreak, but kept as placeholder | |
set lbr | |
set tw=50000 | |
set autoindent | |
set smartindent | |
" Wrap lines | |
set wrap | |
set colorcolumn=100 | |
colo koehler | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Remap VIM 0 to first non-blank character | |
map 0 ^ | |
if has("mac") || has("macunix") | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
endif | |
" Delete trailing white space on save, useful for Python ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.js :call DeleteTrailingWS() | |
autocmd BufWrite *.css :call DeleteTrailingWS() | |
autocmd BufWrite *.cpp :call DeleteTrailingWS() | |
autocmd BufWrite *.c :call DeleteTrailingWS() | |
autocmd BufWrite *.h :call DeleteTrailingWS() | |
autocmd BufWrite *.hpp :call DeleteTrailingWS() | |
autocmd BufWrite *.rs :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
au BufNewFile,BufRead Jenkinsfile setf groovy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment