Last active
January 30, 2021 07:58
-
-
Save jah2488/f6b04260ccfffde41bed to your computer and use it in GitHub Desktop.
Basic VIM setup
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
filetype plugin indent on " Turn on plugins, auto indentation, and syntax highlighting | |
set nocompatible " Use Vim settings, rather then Vi settings | |
set nobackup " Stop vim from leaving temp files everywhere | |
set nowritebackup " Don't write your undo history to a file | |
set history=200 " Only save 200 undos | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
set vb " NO BELLS! | |
set wildmenu " Turn on the WiLd menu | |
set laststatus=2 " Always display the status line | |
set mousefocus " gvim mouse click will select pane | |
set shell=/bin/sh " Ensure that vim always runs from a shell https://rvm.io/integration/vim | |
set backspace=indent,eol,start "http://vim.wikia.com/wiki/Backspace_and_delete_problems | |
set list listchars=tab:»·,trail:· " Display extra whitespace | |
" Ignore compiled files | |
set wildignore+=*.o,*~,*.pyc | |
set wildignore+="bin/*" | |
set wildignore+="build/*" | |
" Turn on Line Numbers and set width to 4 | |
set number " You can set relative numbers if you prefer those with set relativenumber | |
set numberwidth=4 " How many numbers to allow on the left column. Hope your file isn't longer than 9,999 lines. | |
" Uncommenting these lines will set relative numbers | |
"autocmd InsertEnter * :set number | |
"autocmd InsertLeave * :set relativenumber | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") | |
syntax on | |
endif | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
augroup END | |
" Softtabs, 2 spaces | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
autocmd Filetype html setlocal ts=2 sts=2 sw=2 | |
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2 | |
autocmd Filetype javascript setlocal ts=4 sts=4 sw=4 | |
" Load the Local config if available | |
if filereadable("~/.vimrc.local") | |
source ~/.vimrc.local | |
endif | |
" Use Ack instead of Grep when available (You should really check out Ack it is awesome http://beyondgrep.com/) | |
if executable("ack") | |
set grepprg=ack\ -H\ --nogroup\ --nocolor | |
endif | |
" Delete trailing white space function | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
" Call delete trailing whitespace fn when these file types are saved | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.rb :call DeleteTrailingWS() | |
autocmd BufWrite *.erb :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
autocmd BufWrite *.js :call DeleteTrailingWS() | |
" Tab completion options | |
set wildmode=list:longest,list:full | |
set complete=.,w,t | |
" Get off my lawn | |
nnoremap <Left> :echoe "Use h"<CR> | |
nnoremap <Right> :echoe "Use l"<CR> | |
nnoremap <Up> :echoe "Use k"<CR> | |
nnoremap <Down> :echoe "Use j"<CR> | |
"Use TAB to complete when typing words, else inserts TABs as usual. | |
"Uses dictionary and source files to find matching words to complete. | |
"See help completion for source, | |
"Note: usual completion is on <C-n> but more trouble to press all the time. | |
"Never type the same word twice and maybe learn a new spellings! | |
"Use the Linux dictionary when spelling is in doubt. | |
"Window users can copy the file to their machine. | |
function! Tab_Or_Complete() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-N>" | |
else | |
return "\<Tab>" | |
endif | |
endfunction | |
inoremap <Tab> <C-R>=Tab_Or_Complete()<CR> | |
set dictionary="/usr/dict/words" | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/node_modules/*,*/bower_components/* " MacOSX/Linux | |
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows |
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
" This basic config file for vim with some settings that I have enjoyed over | |
" the years. This config files assumes (and hopes) you will install the | |
" following plugins: | |
" Pathogen - https://github.com/tpope/vim-pathogen (Do this first) | |
" NERDTree - https://github.com/scrooloose/nerdtree | |
" Syntastic - https://github.com/scrooloose/syntastic | |
" Ctrl-P - https://github.com/kien/ctrlp.vim | |
" StatusBar - https://github.com/powerline/powerline | |
" Airline - https://github.com/bling/vim-airline | |
" Tomorrow Themes - https://github.com/ChrisKempson/Vim-Tomorrow-Theme | |
filetype plugin indent on " Turn on plugins, auto indentation, and syntax highlighting | |
set nocompatible " Use Vim settings, rather then Vi settings | |
set nobackup " Stop vim from leaving temp files everywhere | |
set nowritebackup " Don't write your undo history to a file | |
set history=200 " Only save 200 undos | |
set ruler " show the cursor position all the time | |
set showcmd " display incomplete commands | |
set incsearch " do incremental searching | |
set vb " NO BELLS! | |
set wildmenu " Turn on the WiLd menu | |
set laststatus=2 " Always display the status line | |
set mousefocus " gvim mouse click will select pane | |
set shell=/bin/sh " Ensure that vim always runs from a shell https://rvm.io/integration/vim | |
set backspace=indent,eol,start "http://vim.wikia.com/wiki/Backspace_and_delete_problems | |
set list listchars=tab:»·,trail:· " Display extra whitespace | |
" Ignore compiled files | |
set wildignore+=*.o,*~,*.pyc | |
set wildignore+="bin/*" | |
set wildignore+="build/*" | |
" Turn on Line Numbers and set width to 4 | |
set number " You can set relative numbers if you prefer those with set relativenumber | |
set numberwidth=4 " How many numbers to allow on the left column. Hope your file isn't longer than 9,999 lines. | |
" Uncommenting these lines will set relative numbers | |
"autocmd InsertEnter * :set number | |
"autocmd InsertLeave * :set relativenumber | |
call pathogen#infect() " Turn on pathogen (this will load all the plugins from your bundle folder) | |
" Switch syntax highlighting on, when the terminal has colors | |
" Also switch on highlighting the last used search pattern. | |
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") | |
syntax on | |
endif | |
" Where you set your colorscheme | |
" More here: https://github.com/flazz/vim-colorschemes | |
" : http://vimcolors.com/ | |
colorscheme Tomorrow-Night-Bright | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
augroup END | |
" Softtabs, 2 spaces | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
autocmd Filetype html setlocal ts=2 sts=2 sw=2 | |
autocmd Filetype ruby setlocal ts=2 sts=2 sw=2 | |
autocmd Filetype javascript setlocal ts=4 sts=4 sw=4 | |
" Load the Local config if available | |
if filereadable("~/.vimrc.local") | |
source ~/.vimrc.local | |
endif | |
" Use Ack instead of Grep when available (You should really check out Ack it is awesome http://beyondgrep.com/) | |
if executable("ack") | |
set grepprg=ack\ -H\ --nogroup\ --nocolor | |
endif | |
" Delete trailing white space function | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
" Call delete trailing whitespace fn when these file types are saved | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.rb :call DeleteTrailingWS() | |
autocmd BufWrite *.erb :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
autocmd BufWrite *.js :call DeleteTrailingWS() | |
" Tab completion options | |
set wildmode=list:longest,list:full | |
set complete=.,w,t | |
" Get off my lawn | |
" Uncommenting these lines will disable the arrow keys and make you a true vim hero | |
"nnoremap <Left> :echoe "Use h"<CR> | |
"nnoremap <Right> :echoe "Use l"<CR> | |
"nnoremap <Up> :echoe "Use k"<CR> | |
"nnoremap <Down> :echoe "Use j"<CR> | |
"""""" NERDTree Toggle command | |
" Leader is \ by default | |
" For example, hitting backslash 2x would open/close the nerd tree window (when in normal mode) | |
map <leader><leader> :NERDTreeToggle<CR> | |
"""" NERD TREE Settings | |
"" Open Nerd Tree when vim starts | |
autocmd vimenter * NERDTree | call feedkeys("\<C-\>\<C-n>\<c-w>l", 'n') | |
"" Close vim when only open window is nerd tree | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
" Don't show node_modules or bower_components in nerd tree | |
let NERDTreeIgnore = ['(node_modules|bower_components)$'] | |
"Use TAB to complete when typing words, else inserts TABs as usual. | |
"Uses dictionary and source files to find matching words to complete. | |
"See help completion for source, | |
"Note: usual completion is on <C-n> but more trouble to press all the time. | |
"Never type the same word twice and maybe learn a new spellings! | |
"Use the Linux dictionary when spelling is in doubt. | |
"Window users can copy the file to their machine. | |
function! Tab_Or_Complete() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-N>" | |
else | |
return "\<Tab>" | |
endif | |
endfunction | |
inoremap <Tab> <C-R>=Tab_Or_Complete()<CR> | |
set dictionary="/usr/dict/words" | |
" Syntastic settings | |
let g:syntastic_ruby_checkers=['mri'] | |
let g:syntastic_ruby_exec='ruby' | |
let g:syntastic_check_on_open=1 | |
let g:syntastic_enable_signs=1 | |
let g:syntastic_echo_current_error=1 | |
let g:syntastic_enable_balloons = 1 | |
let g:syntastic_javascript_checkers = ['jshint'] | |
let g:syntastic_error_symbol='✘' | |
let g:syntastic_warning_symbol='⇒' | |
"Control-P Settings | |
" For example, hitting Ctrl + p will open the CtrlP fuzzyfinder | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/node_modules/*,*/bower_components/* " MacOSX/Linux | |
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment