Created
January 3, 2017 22:58
-
-
Save typpo/3b1cf1688b98d941aa568d05c6d0d3fb to your computer and use it in GitHub Desktop.
naked vimrc
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 nocompatible | |
filetype off | |
set backspace=indent,eol,start | |
" Exit visual mode without delay. | |
set timeoutlen=1000 ttimeoutlen=0 | |
set cul " cursor line | |
set cpo+=J | |
" 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 | |
" 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 | |
inoremap kk <Esc>bdwi | |
" 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 | |
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment