Skip to content

Instantly share code, notes, and snippets.

/.vimrc Secret

Created September 16, 2016 04:53
Show Gist options
  • Save anonymous/20b2a1f43125c0d39932bf430c8137dc to your computer and use it in GitHub Desktop.
Save anonymous/20b2a1f43125c0d39932bf430c8137dc to your computer and use it in GitHub Desktop.
"Pathogen must be called before everything
call pathogen#infect()
set number
set numberwidth=5
set hidden
set showmatch
set wildmode=longest,list
set ruler
set nowrap "set no wrap
set hlsearch "This is to highlight searches
set backspace=2 " Something to do with Mac
set tw=100
"Internalization
set fileencoding=utf8
set fileencodings=ucs-bom,utf8,prc
"http://stackoverflow.com/questions/6210946/prevent-saving-files-with-certain-names-in-vim/6211489#6211489
:autocmd BufWritePre [:;]* try |
\ echoerr 'Suspicious file name ' . expand('<afile>') | endtry
"Enable filetype-specific indenting and plugins
filetype on
filetype plugin indent on
"Remove trailing white space
autocmd BufWritePre * :%s/\s\+$//e
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Color, Scheme
syntax on
set t_Co=256
set background=dark
colorscheme molokai
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Key mapping
"Window Height, Width
map <c-w>, <c-w>10<
map <c-w>. <c-w>10>
map <c-w>- <c-w>10-
map <c-w>+ <c-w>10+
"Tab movements
nnoremap <silent> <C-Right> :tabl<cr>
nnoremap <silent> <C-Left> :tabr<cr>
nnoremap <silent> <C-Up> :tabp<cr>
nnoremap <silent> <C-Down> :tabn<cr>
"Stop Highlighting
:nnoremap <silent> <C-l> :nohl<CR><C-l>
set pastetoggle=<F12>
"Don't use these since we will be mapping <c-w> to tabs
"map <c-h> <c-w>h
"map <c-j> <c-w>j
"map <c-l> <c-w>l
"map <c-k> <c-w>k
"Faster navigation between splits
map <c-h> :wincmd h<CR>
map <c-j> :wincmd j<CR>
map <c-l> :wincmd l<CR>
map <c-k> :wincmd k<CR>
" To encourage adoption of the keys above,
map <c-w>w nop
"Faster for tabs
"Watch out, these are reversed
map <c-w>h :tabr<cr>
map <c-w>l :tabl<cr>
" These are for moving tabs. Don't touch them
"map <c-w>j :tabp<cr>
"map <c-w>k :tabn<cr>
" This is needed to reduce the distracting red default background
hi SpellBad ctermfg=255 ctermbg=093
hi SpellCap ctermfg=255 ctermbg=093
hi Search ctermfg=255 ctermbg=026
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Python
au FileType python set tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent
" \ foldmethod=indent foldcolumn=1 foldlevel=4
"Html
au FileType html set shiftwidth=2
"Ardunio
:set formatoptions+=r " Automatically adds *
"R
"set runtimepath=~/Vim-R-plugin,~/.vim,$VIMRUNTIME,~/.vim/after
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Plugins
"NERDtree
map <F4> :NERDTreeToggle<CR>
let NERDTreeIgnore = ['\.pyc$']
"set splitright " New splits goes to right
"Show NERDTree by default
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
"Place cursor on file and not NERDTree
autocmd VimEnter * wincmd p
"Closing NERDTree if last
function! NERDTreeQuit()
redir => buffersoutput
silent buffers
redir END
" 1BufNo 2Mods. 3File 4LineNo
let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
let windowfound = 0
for bline in split(buffersoutput, "\n")
let m = matchlist(bline, pattern)
if (len(m) > 0)
if (m[2] =~ '..a..')
let windowfound = 1
endif
endif
endfor
if (!windowfound)
quitall
endif
endfunction
autocmd WinEnter * call NERDTreeQuit()
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Syntastic
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_wq = 0
"
"
""if this is 1, then it will be slow to open a file
"let g:syntastic_check_on_open=0
"
"let g:syntastic_javascript_checkers = ['jshint']
"let g:syntastic_python_checkers = ['pylint']
"let g:syntastic_python_pylint_args = '-d W0311,F0401,C0111,C0103,E1101,R0903,W0232,C0301,R0904,relative-import,maybe-no-member,fixme,no-name-in-module,broad-except,too-many-branches,too-many-statements,too-many-instance-attributes,too-many-locals,no-self-use,attribute-defined-outside-init'
"
""Ignore html files because of jinja
"let g:syntastic_mode_map = {
" \ "mode": "active",
" \ "passive_filetypes": ["html"] }
"
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
""isort-vim
:autocmd BufWritePost *.py Isort
""Command-T
"If you navigate to /foo/bar/baz.py and you want to go to /foo/baz/shit.py
"set noautochdir allows you to remain at /foo if you first open the file at /foo
set noautochdir
set wildignore=*.swp,*.bak,*.pyc,*.class,*.jar,*.gif,*.png,*.jpg
function! Git_Repo_Cdup() " Get the relative path to repo root
"Ask git for the root of the git repo (as a relative '../../' path)
let git_top = system('git rev-parse --show-cdup')
let git_fail = 'fatal: Not a git repository'
if strpart(git_top, 0, strlen(git_fail)) == git_fail
" Above line says we are not in git repo. Ugly. Better version?
return ''
else
" Return the cdup path to the root. If already in root,
" path will be empty, so add './'
return './' . git_top
endif
endfunction
function! CD_Git_Root()
execute 'cd '.Git_Repo_Cdup()
let curdir = getcwd()
echo 'CWD now set to: '.curdir
endfunction
nnoremap <LEADER>gr :call CD_Git_Root()<cr>
"Gist
let g:github_user = "vicngtor@gmail.com"
let g:github_token = "f03e95bf2bd4d704dcf266e42d8613c7f8623514"
"Disable R vim plugin mapping of '_' to ' <- '
let vimrplugin_assign = 0
autocmd BufNewFile,BufRead *.ino set formatprg=astyle\ -T4pb
"Fixes NerdTree quit error on buffer unsaved from ssh tunnelling
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Yanking
"if has("clipboard")
" set clipboard=unnamed " copy to the system clipboard
" if has("unnamedplus") " X11 support
" set clipboard+=unnamedplus
" endif
"endif
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"SSH specific
"Yanking across terminal
"vmap "+y :!xclip -f -sel clip<CR>
"map "+p :r!xclip -o -sel clip<CR>
"http://stackoverflow.com/questions/37444399/vim-copy-clipboard-between-mac-and-ubuntu-over-ssh/37445368#37445368
"set clipboard^=unnamed
"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Indentation Specific
"Tabs, default everything is 2
filetype indent on
set nocompatible
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=2
set autoindent
"Python Double indent
let g:pyindent_open_paren = '&sw * 2'
let g:pyindent_continue = '&sw * 2'
let g:pyindent_nested_paren = '&sw'
"Using vim-python-pep8-indent
"let g:pymode_indent = 0
"Html disable indenting cause vim sucks at doing this
"autocmd FileType xml,html set noautoindent indentexpr=""
"Html, disable underlining things betweeb <u> or <b>
let html_no_rendering=1
map <c-f> :call HtmlBeautify()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment