Created
January 26, 2018 20:52
-
-
Save elvircrn/76d0c4913ce6e14ae9a9d50261d91d2b to your computer and use it in GitHub Desktop.
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Full screen mode on start | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
"run the command immediately when starting vim | |
autocmd VimEnter * call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) | |
" activate/deactivate full screen with function key <F11> | |
map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR> | |
filetype on | |
filetype plugin on | |
set runtimepath^=~/.vimrc/bundle/ctrlp.vim | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use ubuntu shell | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" set shell=%windir%\system32\bash.exe | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Auto reload on file change | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set autoread | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Colors | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set t_Co=256 | |
set background=dark | |
highlight Normal ctermbg=NONE | |
highlight nonText ctermbg=NONE | |
" colorscheme base16-railscasts | |
" colorscheme cobalt | |
colorscheme materialtheme | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Vim-ES6 (https://github.com/isRuslan/vim-es6) | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
if &filetype=='js' | |
set syntax=javascript | |
endif | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" ALE (autocomplete) | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:ale_sign_column_always = 1 | |
let g:ale_python_flake8_executable = 'python' "name of executable" | |
let g:ale_python_flake8_options = '-m flake8 python --max-line-length=120' | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Sign column color fix | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
highlight clear SignColumn | |
highlight clear LineNr | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" HELP | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
map <c-F1> :e C:\Program Files (x86)\Vim\useful.txt<CR> | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Plugged | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
call plug#begin('~/.vim/plugged') | |
Plug 'elmcast/elm-vim' | |
Plug 'junegunn/goyo.vim' | |
call plug#end() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Number lines | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set relativenumber | |
set number | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Disable swap files | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nobackup | |
set noswapfile | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Pathogen | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
execute pathogen#infect() | |
filetype plugin indent on | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" AIRLINE | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set laststatus=2 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" DISABLE BEEPING | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set noerrorbells visualbell t_vb= | |
autocmd GUIEnter * set visualbell t_vb= | |
syntax on | |
source $VIMRUNTIME/vimrc_example.vim | |
source $VIMRUNTIME/mswin.vim | |
" behave mswin | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Buffers | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
imap <F2> :bprev<CR> | |
imap <F3> :bnext<CR> | |
nmap <F2> :bprev<CR> | |
nmap <F3> :bnext<CR> | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" CtrlP | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:ctrlp_map = '<c-t>' | |
let g:ctrlp_cmd = 'CtrlP' | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] | |
let g:ctrlp_max_files=0 | |
let g:ctrlp_max_depth=40 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" STATUS LINE | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Anaconda | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" if &ft == 'py' | |
" map <F5> <cr> :!"C:\Program Files\Anaconda3\python.exe" "%:p"<cr> | |
" endif | |
" Bind F5 to save file if modified and execute python script in a buffer. | |
nnoremap <silent> <F5> :call SaveAndExecutePython()<CR> | |
vnoremap <silent> <F5> :<C-u>call SaveAndExecutePython()<CR> | |
function! SaveAndExecutePython() | |
" SOURCE [reusable window]: https://github.com/fatih/vim-go/blob/master/autoload/go/ui.vim | |
" save and reload current file | |
silent execute "update | edit" | |
" get file path of current file | |
let s:current_buffer_file_path = expand("%") | |
let s:output_buffer_name = "Python" | |
let s:output_buffer_filetype = "output" | |
" reuse existing buffer window if it exists otherwise create a new one | |
if !exists("s:buf_nr") || !bufexists(s:buf_nr) | |
silent execute 'botright new ' . s:output_buffer_name | |
let s:buf_nr = bufnr('%') | |
elseif bufwinnr(s:buf_nr) == -1 | |
silent execute 'botright new' | |
silent execute s:buf_nr . 'buffer' | |
elseif bufwinnr(s:buf_nr) != bufwinnr('%') | |
silent execute bufwinnr(s:buf_nr) . 'wincmd w' | |
endif | |
silent execute "setlocal filetype=" . s:output_buffer_filetype | |
setlocal bufhidden=delete | |
setlocal buftype=nofile | |
setlocal noswapfile | |
setlocal nobuflisted | |
setlocal winfixheight | |
setlocal cursorline " make it easy to distinguish | |
setlocal nonumber | |
setlocal norelativenumber | |
setlocal showbreak="" | |
" clear the buffer | |
setlocal noreadonly | |
setlocal modifiable | |
%delete _ | |
" add the console output | |
silent execute ".!\"C:\\Program Files\\Anaconda3\\python.exe\" " . shellescape(s:current_buffer_file_path, 1) | |
" resize window to content length | |
" Note: This is annoying because if you print a lot of lines then your code buffer is forced to a height of one line every time you run this function. | |
" However without this line the buffer starts off as a default size and if you resize the buffer then it keeps that custom size after repeated runs of this function. | |
" But if you close the output buffer then it returns to using the default size when its recreated | |
"execute 'resize' . line('$') | |
" make the buffer non modifiable | |
setlocal readonly | |
setlocal nomodifiable | |
endfunction | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Split switching | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
nnoremap <c-j> <c-w>j | |
nnoremap <c-k> <c-w>k | |
nnoremap <c-h> <c-w>h | |
nnoremap <c-l> <c-w>l | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" GUI | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set guioptions -=m | |
set guioptions -=T | |
set guioptions-=r "remove right-hand scroll bar | |
set guioptions-=L "remove left-hand scroll bar | |
" set guifont=Monaco:h9:cANSI:qDRAFT | |
set guifont=Consolas:h10 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Hexmode | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" ex command for toggling hex mode - define mapping if desired | |
command -bar Hexmode call ToggleHex() | |
" helper function to toggle hex mode | |
function ToggleHex() | |
" hex mode should be considered a read-only operation | |
" save values for modified and read-only for restoration later, | |
" and clear the read-only flag for now | |
let l:modified=&mod | |
let l:oldreadonly=&readonly | |
let &readonly=0 | |
let l:oldmodifiable=&modifiable | |
let &modifiable=1 | |
if !exists("b:editHex") || !b:editHex | |
" save old options | |
let b:oldft=&ft | |
let b:oldbin=&bin | |
" set new options | |
setlocal binary " make sure it overrides any textwidth, etc. | |
silent :e " this will reload the file without trickeries | |
"(DOS line endings will be shown entirely ) | |
let &ft="xxd" | |
" set status | |
let b:editHex=1 | |
" switch to hex editor | |
%!xxd | |
else | |
" restore old options | |
let &ft=b:oldft | |
if !b:oldbin | |
setlocal nobinary | |
endif | |
" set status | |
let b:editHex=0 | |
" return to normal editing | |
%!xxd -r | |
endif | |
" restore values for modified and read only state | |
let &mod=l:modified | |
let &readonly=l:oldreadonly | |
let &modifiable=l:oldmodifiable | |
endfunction | |
" nnoremap <C-H> :Hexmode<CR> | |
" inoremap <C-H> <Esc>:Hexmode<CR> | |
" vnoremap <C-H> :<C-U>Hexmode<CR> | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" wat | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set diffexpr=MyDiff() | |
function MyDiff() | |
let opt = '-a --binary ' | |
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif | |
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif | |
let arg1 = v:fname_in | |
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif | |
let arg2 = v:fname_new | |
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif | |
let arg3 = v:fname_out | |
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif | |
if $VIMRUNTIME =~ ' ' | |
if &sh =~ '\<cmd' | |
if empty(&shellxquote) | |
let l:shxq_sav = '' | |
set shellxquote& | |
endif | |
let cmd = '"' . $VIMRUNTIME . '\diff"' | |
else | |
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' | |
endif | |
else | |
let cmd = $VIMRUNTIME . '\diff' | |
endif | |
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 | |
if exists('l:shxq_sav') | |
let &shellxquote=l:shxq_sav | |
endif | |
endfunction | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" DirectX | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
if has("directx") && $VIM_USE_DIRECTX != '0' | |
set renderoptions=type:directx,taamode:1 | |
endif | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Always start vim in fullscreen | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
au GUIEnter * simalt ~x | |
let extension = expand('%:e') | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Tabs, Html/CSS Formatting | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
if extension=="html" || extension=="css" || extension=="asm" | |
set tabstop=2 | |
set shiftwidth=2 | |
set number | |
set expandtab | |
else | |
set tabstop=2 | |
set shiftwidth=2 | |
set number | |
set expandtab | |
endif | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" LaTeX | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" if extension=="tex" | |
" set encoding=utf8 | |
" endif | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Fuck swap files | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set backup | |
set backupdir=C:\WINDOWS\Temp | |
set backupskip=C:\WINDOWS\Temp\* | |
set directory=C:\WINDOWS\Temp | |
set writebackup | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Cursorline | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set cursorline | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" ALE | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:ale_linters = {'rust': ['rustc'], 'javascript': ['standard']} | |
let g:ale_fix_on_save = 1 | |
" Enable the list of buffers | |
let g:airline#extensions#tabline#enabled = 1 | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Airline | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" BuffOnly - Delete all the buffers except the current/named buffer | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Copyright November 2003 by Christian J. Robinson <[email protected]> | |
" | |
" Distributed under the terms of the Vim license. See ":help license". | |
" | |
" Usage: | |
" | |
" :Bonly / :BOnly / :Bufonly / :BufOnly [buffer] | |
" | |
" Without any arguments the current buffer is kept. With an argument the | |
" buffer name/number supplied is kept. | |
command! -nargs=? -complete=buffer -bang Bonly | |
\ :call BufOnly('<args>', '<bang>') | |
command! -nargs=? -complete=buffer -bang BOnly | |
\ :call BufOnly('<args>', '<bang>') | |
command! -nargs=? -complete=buffer -bang Bufonly | |
\ :call BufOnly('<args>', '<bang>') | |
command! -nargs=? -complete=buffer -bang BufOnly | |
\ :call BufOnly('<args>', '<bang>') | |
function! BufOnly(buffer, bang) | |
if a:buffer == '' | |
" No buffer provided, use the current buffer. | |
let buffer = bufnr('%') | |
elseif (a:buffer + 0) > 0 | |
" A buffer number was provided. | |
let buffer = bufnr(a:buffer + 0) | |
else | |
" A buffer name was provided. | |
let buffer = bufnr(a:buffer) | |
endif | |
if buffer == -1 | |
echohl ErrorMsg | |
echomsg "No matching buffer for" a:buffer | |
echohl None | |
return | |
endif | |
let last_buffer = bufnr('$') | |
let delete_count = 0 | |
let n = 1 | |
while n <= last_buffer | |
if n != buffer && buflisted(n) | |
if a:bang == '' && getbufvar(n, '&modified') | |
echohl ErrorMsg | |
echomsg 'No write since last change for buffer' | |
\ n '(add ! to override)' | |
echohl None | |
else | |
silent exe 'bdel' . a:bang . ' ' . n | |
if ! buflisted(n) | |
let delete_count = delete_count+1 | |
endif | |
endif | |
endif | |
let n = n+1 | |
endwhile | |
if delete_count == 1 | |
echomsg delete_count "buffer deleted" | |
elseif delete_count > 1 | |
echomsg delete_count "buffers deleted" | |
endif | |
endfunction | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment