Created
August 3, 2017 17:27
-
-
Save typpo/e5da670ee653d5fe211216655364b381 to your computer and use it in GitHub Desktop.
macbook vimrc 2017-08-03
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
set nocompatible | |
filetype indent on | |
set backspace=indent,eol,start | |
set cul " cursor line | |
set cpo+=J | |
" Exit visual mode without delay. | |
set timeoutlen=1000 ttimeoutlen=0 | |
" causes python problems: | |
" set smartindent | |
" inoremap # X^H# | |
set cindent | |
set smarttab | |
set nu | |
set rnu | |
set ic | |
set ts=2 | |
set sw=2 | |
set softtabstop=2 | |
set expandtab | |
set background=dark | |
set lazyredraw | |
" highlight last inserted text | |
nmap gV `[v`] | |
let mapleader="," " leader is comma | |
" move vertically by visual line | |
" Removed because it ruins relative moving... | |
" nnoremap j gj | |
" nnoremap k gk | |
" right bar | |
set colorcolumn=80 | |
highlight ColorColumn ctermbg=7 | |
syntax on | |
filetype plugin indent on | |
au BufNewFile,BufRead *.djs set filetype=javascript | |
" Search highlighting - highlight in light blue, unlighting on press space | |
set hlsearch | |
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR> | |
:hi Search ctermbg=LightBlue | |
" Automatically cd into the directory that the file is in | |
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ') | |
" autocmd BufEnter * if expand('%:p') !~ '://' | execute "chdir ".escape(expand("%:p:h"), ' ') | endif | |
" Attempting to set title string of window | |
autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" | |
" 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 | |
" Compatible for some vim features | |
"set nocompatible | |
" shows what you are typing as a command | |
"set showcmd | |
inoremap kk <Esc>bdwi | |
" When I close a tab, remove the buffer | |
"set nohidden | |
" Create Blank Newlines and stay in Normal mode | |
nnoremap <silent> zj o<Esc> | |
nnoremap <silent> zk O<Esc> | |
" Blank out line and stay in Normal mode | |
nnoremap <silent> zs ^<S-C><Esc> | |
" Easier buffer switching | |
map <C-j> :bprev<CR> | |
map <C-k> :bnext<CR> | |
set hidden " allow hide buffers with no write | |
" bash like tab completion | |
set wildmenu | |
set wildmode=list:longest | |
" use ctrl-h/j/k/l to switch between splits | |
"map <c-j> <c-w>j | |
"map <c-k> <c-w>k | |
"map <c-l> <c-w>l | |
"map <c-h> <c-w>h | |
augroup filetype | |
au BufNewFile,BufRead *.html set filetype=php | |
au BufNewFile,BufRead *.phpt set filetype=php | |
au BufNewFile,BufRead *.inc set filetype=php | |
au BufNewFile,BufRead *.template set filetype=htmljinja | |
augroup END | |
" Indent Python in the Google way. | |
setlocal indentexpr=GetGooglePythonIndent(v:lnum) | |
let s:maxoff = 50 " maximum number of lines to look backwards. | |
function GetGooglePythonIndent(lnum) | |
" Indent inside parens. | |
" Align with the open paren unless it is at the end of the line. | |
" E.g. | |
" open_paren_not_at_EOL(100, | |
" (200, | |
" 300), | |
" 400) | |
" open_paren_at_EOL( | |
" 100, 200, 300, 400) | |
call cursor(a:lnum, 1) | |
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW', | |
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" | |
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" | |
\ . " =~ '\\(Comment\\|String\\)$'") | |
if par_line > 0 | |
call cursor(par_line, 1) | |
if par_col != col("$") - 1 | |
return par_col | |
endif | |
endif | |
" Delegate the rest to the original function. | |
return GetPythonIndent(a:lnum) | |
endfunction | |
let pyindent_nested_paren="&sw*2" | |
let pyindent_open_paren="&sw*2" | |
" Vundles | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
Bundle 'Valloric/YouCompleteMe' | |
Bundle 'fholgado/minibufexpl.vim' | |
Bundle 'groenewege/vim-less' | |
nnoremap ,m :w <BAR> !lessc % > %:t:r.css<CR><space> | |
au BufNewFile,BufRead *.less set filetype=less | |
Bundle 'maciakl/vim-neatstatus' | |
Bundle 'kien/ctrlp.vim' | |
let g:ctrlp_map = '<c-p>' | |
" https://github.com/kien/ctrlp.vim | |
let g:ctrlp_working_path_mode = 'ra' | |
let g:ctrlp_root_markers = ['.repo'] | |
" set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux | |
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* | |
let g:ctrlp_custom_ignore = '\.(git\|hg\|svn\|repo)' | |
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux | |
"let g:ctrlp_use_caching = 0 | |
let g:ctrlp_cache_dir = $HOME.'/.ctrlp/cache' | |
Bundle 'rainux/vim-desert-warm-256' | |
set t_Co=256 | |
colorscheme desert-warm-256 | |
" Js | |
Bundle "pangloss/vim-javascript" | |
" Bundle "marijnh/tern_for_vim" | |
" nnoremap <F2> :TernDef<CR> | |
" nnoremap <F3> :TernRefs<CR> | |
" nnoremap <F4> :TernRename<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment