Skip to content

Instantly share code, notes, and snippets.

@taywils
Last active May 21, 2024 04:56
Show Gist options
  • Save taywils/6017301 to your computer and use it in GitHub Desktop.
Save taywils/6017301 to your computer and use it in GitHub Desktop.
My Mac OS X .vimrc for fresh installs
" Enable Pathogen
execute pathogen#infect()
" Enable Syntax
syntax on
" Enable Autowrite
set autowrite
" Indent based upon filetype when possible
filetype plugin indent on
" Don't save backups
set nobk
" Tab & Spaces "
" Will highlight vertical and horizontal tabs
set listchars=tab:\|-
set tabstop=2
set shiftwidth=2
set softtabstop=2
" Keeps vim from converting spaces into tabs
set expandtab
" Turn on tab listchars
set list
" Use k and j to move between horizontal buffers when Ctrl is held down
" Use l and h to move between vertical buffers when Ctrl is held down
map <C-J> <C-W>j<C-W>
map <C-K> <C-W>k<C-W>
map <C-L> <C-W>l<C-W>
map <C-H> <C-W>h<C-W>
" Always show the statusline
set laststatus=2
" Ignores case when searching
set ignorecase
" Don't save swapfiles
set noswapfile
" Auto start NERDTree and focus the window
au VimEnter * NERDTree
au VimEnter * wincmd p
" https://stackoverflow.com/questions/53657545/nerdtree-g-before-folder-and-file-names-osx-terminal-vim
let g:NERDTreeNodeDelimiter = "\u00a0"
" Show hidden files
let NERDTreeShowHidden=1
" OmniComplete
set ofu=syntaxcomplete#Complete
" Highlight overrides for [term, ctermfg, ctermbg]
highlight clear
" OmniComplete Green Theme
highlight Pmenu ctermfg=0 ctermbg=2
highlight PmenuSel ctermfg=0 ctermbg=7
highlight PmenuSbar ctermfg=7 ctermbg=0
highlight PmenuThumb ctermfg=0 ctermbg=7
" Search
highlight Search ctermfg=0
" Auto indent text and stuff
set autoindent
" Auto indent braces, (C-style)
set cindent
" Show line numbers
set number
" C++
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++1y -stdlib=libc++'
" SEARCH HACKS
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>
" NERDTree Open current file in tree viewer
" Check if NERDTree is open or active
function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
" file, and we're not in vimdiff
function! SyncTree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
" Highlight currently open buffer in NERDTree
autocmd BufEnter * call SyncTree()
" git://github.com/airblade/vim-gitgutter.git
set updatetime=100
" no error bells
set noerrorbells
" papercolor-theme
set background=dark
colorscheme PaperColor
" typescript
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescriptreact
set t_Co=256
" coc-prettier
command! -nargs=0 Prettier :call CocAction('runCommand', 'prettier.formatFile')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment