Last active
March 4, 2020 13:50
-
-
Save Bad-ptr/c880141ad3a68e4e4bc0 to your computer and use it in GitHub Desktop.
Vim settings, compatible with vim.tiny
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
"Basic Settings {{{1 | |
scriptencoding utf-8 | |
set nocompatible | |
set encoding=utf-8 | |
set termencoding=utf-8 | |
set fileencoding=utf-8 | |
set ffs=unix,dos,mac | |
set modeline | |
set modelines=3 | |
set history=700 | |
set undolevels=1000 | |
set clipboard=unnamed | |
if has('unnamedplus') | |
set clipboard=unnamed,unnamedplus | |
endif | |
set noerrorbells | |
set novisualbell | |
set visualbell | |
set t_vb= | |
set tm=500 | |
set lazyredraw | |
set notimeout ttimeout ttimeoutlen=200 | |
set hidden | |
"set autowrite | |
"set autoread | |
set confirm | |
set number | |
set showcmd | |
set showmode | |
set ruler | |
set laststatus=2 | |
set statusline=%<%f\ (%{&ff}/%Y)\ %-4(%m%)%-19(%3l,%02c%03V%) | |
set cursorline | |
"set cursorcolumn | |
set wildchar=<TAB> | |
set wildmenu | |
set wildmode=longest,list,full | |
"set cmdheight=2 | |
set showtabline=2 | |
set switchbuf=newtab | |
set completeopt=menuone,longest | |
set autoindent | |
set smartindent | |
"set copyindent | |
set splitbelow | |
"set wrap | |
set nowrap | |
set linebreak | |
set textwidth=0 | |
set showbreak=>\ \ \ | |
set colorcolumn=85 | |
set scrolloff=7 | |
set sidescroll=5 | |
set virtualedit=block | |
set whichwrap+=<,>,[,] | |
set showmatch | |
set matchtime=2 | |
setglobal display=lastline,uhex | |
set formatoptions=c,q,r,t | |
"set background=light | |
"set backspace=eol,start,indent | |
set bs=2 | |
set magic | |
set diffopt=filler,vertical,iwhite | |
set listchars=tab:>.,trail:~,precedes:>,extends:> | |
"set list | |
" KeyBindings {{{2 | |
cnoremap w!! w !sudo tee > /dev/null % | |
nnoremap gV `[v`] | |
nnoremap <leader>s :mksession<CR> | |
nnoremap <leader>l :set list!<CR> | |
inoremap ii <Esc> | |
vnoremap <F2> "cy:@c<cr> | |
nnoremap <F2> "cyy:@c<cr> | |
inoremap <C-e> <Esc>A | |
inoremap <C-a> <Esc>I | |
" }}} | |
" Tabs/Spaces {{{2 | |
set tabstop=4 | |
set softtabstop=2 | |
set shiftwidth=2 | |
"set shiftround | |
set smarttab | |
set expandtab | |
" }}} | |
" Search {{{2 | |
set incsearch | |
set hlsearch | |
set ignorecase | |
set smartcase | |
nnoremap <leader><space> :nohlsearch<CR> | |
" }}} | |
" Backups {{{2 | |
set backup | |
set backupdir=~/.vim/backup,~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set backupskip=/tmp/*,/private/tmp/* | |
set directory=~/.vim/swp,~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set writebackup | |
"set nobackup | |
"set nowb | |
"set noswapfile | |
" }}} | |
" Persistent undo {{{2 | |
if has('persistent_undo') | |
set undodir=~/.vim/undo | |
set undofile | |
endif | |
" }}} | |
"}}} | |
if !1 | finish | endif | |
"This will not work in vim.tiny {{{1 | |
if exists('g:my_vimrc_loaded') && g:my_vimrc_loaded | finish | endif | |
syntax enable | |
filetype plugin indent on | |
set mouse=a | |
highlight ExtraWhitespace ctermbg=red guibg=red | |
" Functions {{{2 | |
function! MkNonExDir(file, buf) | |
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' | |
let dir=fnamemodify(fnamemodify(a:file, ':p'), ':h') | |
if !isdirectory(dir) | |
"execute "silent! !mkdir -p ".shellescape(dir,1) | |
"redraw! | |
call mkdir(dir, 'p') | |
endif | |
endif | |
endfunction | |
function! Rename(name, bang) | |
let l:curfile=expand("%:p") | |
let l:curpath=expand("%:h").'/' | |
let l:name=fnamemodify(a:name,':p') | |
if l:name=~#'^[/\\\\]' | |
execute "saveas".a:bang." ".fnameescape(l:name) | |
else | |
execute "saveas".a:bang." ".fnameescape(l:curpath.l:name) | |
endif | |
let l:oldfile=l:curfile | |
let l:curfile=expand("%:p") | |
if l:curfile !=# l:oldfile && filewritable(l:curfile) | |
execute "bwipe! ".fnameescape(l:oldfile) | |
if delete(l:oldfile) | |
echoerr "Could not delete ".l:oldfile | |
endif | |
endif | |
endfunction | |
function! AppendModeline() | |
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d %set :", | |
\ &tabstop, &shiftwidth, &textwidth, &expandtab ? '' : 'no') | |
let l:modeline = substitute(&commentstring, "%s", l:modeline, "") | |
call append(line("$"), l:modeline) | |
endfunction | |
function! ListCurrentFilePath(a,l,p) | |
return [expand("%:p")] | |
endfunction | |
function! ListCurrentWord(a,l,p) | |
return [expand("<cword>")] | |
endfunction | |
" }}} | |
" Autocommands {{{2 | |
augroup vimrcaugroup | |
autocmd! | |
autocmd FileType Makefile set noexpandtab | |
autocmd FileType vim :execute "command! -buffer Ws :w <bar> source %"| | |
\setlocal softtabstop=4 | setlocal shiftwidth=4 | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
autocmd BufWritePre * :%s/\s\+$//e | |
autocmd BufWritePre * :call MkNonExDir(expand('<afile>'), +expand('<abuf>')) | |
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ | |
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ | |
autocmd InsertLeave * match ExtraWhitespace /\s\+$/ | |
augroup END | |
" }}} | |
" Commands {{{2 | |
command! -nargs=+ -bang -complete=customlist,ListCurrentFilePath | |
\ Rename :call Rename("<args>","<bang>") | |
"cnoreabbrev Rename Rename <C-r>=expand('%:p')<CR> | |
command! -nargs=0 Bd set buflisted | bp | sp | bn | bd | |
command! -nargs=+ -complete=customlist,ListCurrentWord | |
\ Rgrep execute 'silent grep -R -I -n . -e <args>'| | |
\copen|execute 'silent /<args>'|redraw! | |
" }}} | |
" KeyBindings {{{2 | |
let mapleader="," | |
nnoremap <leader>k :Bd<cr> | |
nnoremap <leader>ml :call AppendModeline()<cr> | |
vnoremap <F2> "cy:<c-u>exe join(split(getreg("c"),"\n"),'<bar>')<cr> | |
nnoremap <F2> :exe getline(".")<cr> | |
noremap ,cc :<C-B>silent <C-E>s/\V\.\*/\= | |
\printf(&commentstring,getline("."))/<CR> | |
\:nohlsearch<CR> | |
noremap ,cu :<C-B>silent <C-E>s/\V\^<C-R>= | |
\escape(get(split(&commentstring,'%s'),0,''),'\/').'\\|'. | |
\escape(get(split(&commentstring,'%s'),1,''),'\/') | |
\<CR>\$//g<CR>:nohlsearch<CR> | |
" }}} | |
" Folding {{{2 | |
set foldenable | |
set foldlevelstart=10 | |
set foldnestmax=10 | |
set foldmethod=indent | |
nnoremap <space> za | |
" }}} | |
" Plugins {{{2 | |
let s:my_plugins_include=['fuzzyfinder', 'autocomplpop', 'vim-rsi', | |
\ 'vim-multiple-cursors', 'vim-qfreplace', | |
\ 'gundo.vim', 'tagbar', 'changesPlugin', 'vim-signify', | |
\ 'ZoomWin', 'GoldenView.Vim', | |
\ 'a.vim', 'tcomment_vim', 'wrap-with.vim', 'sparkup'] | |
let s:my_plugins=glob('~/.vim/bundle/*',1,1) | |
if exists('s:my_plugins_exclude') | |
let s:my_plugins=filter(s:my_plugins,"v:val !~# '".join(s:my_plugin_exclude,'\|')."'") | |
endif | |
if exists('s:my_plugins_include') | |
let s:my_plugins=filter(s:my_plugins,"v:val =~# '".join(s:my_plugins_include,'\|')."'") | |
endif | |
" Libs {{{3 | |
set runtimepath+=~/.vim/bundle/l9 | |
" }}} | |
execute "set runtimepath+=".join(s:my_plugins,',') | |
" FuzzyFinder {{{3 | |
let g:fuf_dataDir="~/.vim/.vim-fuf-data" | |
nnoremap <leader>b :FufBuffer<cr> | |
nnoremap <leader>f :FufFileWithCurrentBufferDir<cr> | |
nnoremap <leader>d :FufDirWithCurrentBufferDir<cr> | |
nnoremap <leader>g :FufLine<cr> | |
" }}} | |
" Gundo {{{3 | |
nnoremap <F3> :GundoToggle<CR> | |
" }}} | |
" tagbar {{{3 | |
let g:tagbar_autoclose=0 | |
nnoremap <silent> <F4> :TagbarToggle<CR> | |
" }}} | |
" changes {{{3 | |
let g:changes_sign_text_utf8=1 | |
let g:changes_linehi_diff=0 | |
let g:changes_fixed_sign_column=1 | |
let g:changes_fast=1 | |
" }}} | |
" }}} | |
let g:my_vimrc_loaded=1 | |
"}}} | |
" vim:foldmethod=marker:foldlevel=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment