├── .github └── FUNDING.yml ├── README.markdown └── plugin └── sensible.vim /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: tpope 2 | custom: ["https://www.paypal.me/vimpope"] 3 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # sensible.vim 2 | 3 | Think of sensible.vim as one step above `'nocompatible'` mode: a universal 4 | set of defaults that (hopefully) everyone can agree on. 5 | 6 | * If you're new to Vim, you can install this as a starting point, rather than 7 | copying some random vimrc you found. 8 | * If you're pair programming and you can't agree on whose vimrc to use, this 9 | can be your neutral territory. 10 | * If you're administrating a server with an account that's not exclusively 11 | yours, you can `scp` this up to make things a bit more tolerable. 12 | * If you're troubleshooting a plugin and need to rule out interference from 13 | your vimrc, having this installed will ensure you still have some basic 14 | amenities. 15 | 16 | ## Installation 17 | 18 | Install using your favorite package manager, or use Vim's built-in package 19 | support: 20 | 21 | mkdir -p ~/.vim/pack/tpope/start 22 | cd ~/.vim/pack/tpope/start 23 | git clone https://tpope.io/vim/sensible.git 24 | 25 | ## Features 26 | 27 | See the [source][] for the authoritative list of features. (Don't worry, it's 28 | mostly `:set` calls.) Here's a taste: 29 | 30 | * `'backspace'`: Backspace through anything in insert mode. 31 | * `'incsearch'`: Start searching before pressing enter. 32 | * `'listchars'`: Makes `:set list` (visible whitespace) prettier. 33 | * `'scrolloff'`: Always show at least one line above/below the cursor. 34 | * `'autoread'`: Autoload file changes. You can undo by pressing `u`. 35 | * `runtime! macros/matchit.vim`: Load the version of matchit.vim that ships 36 | with Vim. 37 | 38 | [source]: https://github.com/tpope/vim-sensible/tree/master/plugin/sensible.vim 39 | 40 | ## FAQ 41 | 42 | > How can I see what this plugin actually does? 43 | 44 | The [source][] is authoritative. Use `:help 'option'` to see the 45 | documentation for an option. If you install [scriptease.vim][], you can press 46 | `K` on an option (or command, or function) to jump to its documentation. 47 | 48 | [scriptease.vim]: https://github.com/tpope/vim-scriptease 49 | 50 | > How can I override a setting? 51 | 52 | Normally, sensible.vim loads after your vimrc, making it a bit tricky to 53 | override (although you could use `after/plugin/sensible.vim`). If you want to 54 | load it earlier, add the following line to your vimrc, then put your overrides 55 | below. 56 | 57 | runtime! plugin/sensible.vim 58 | 59 | Feel free to [let me know][GitHub issues] which setting you object to, so I 60 | can reassess whether it makes sense to include it. 61 | 62 | ## Contributing 63 | 64 | I want this to be a plugin nobody objects to installing. [Let me 65 | know][GitHub issues] if you have any objections to *anything*. There are a 66 | handful of settings I figured *might* be controversial, but I included 67 | anyways, just to settle the question once and for all. It won't take much 68 | persuasion for me to remove them. Everything else is negotiable. 69 | 70 | Feel free to ask a question if you're not sure why I've set something, as I 71 | haven't put much effort into documenting that. 72 | 73 | I'm a stickler for [commit messages][], so if you send me a pull request with 74 | so much as a superfluous period in the subject line, I will close it without 75 | so much as a second thought, and save my precious attention for someone who 76 | can actually follow directions. 77 | 78 | [GitHub issues]: http://github.com/tpope/vim-sensible/issues 79 | [commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 80 | 81 | ## Self-Promotion 82 | 83 | Like sensible.vim? Follow the repository on 84 | [GitHub](https://github.com/tpope/vim-sensible) and vote for it on 85 | [vim.org](http://www.vim.org/scripts/script.php?script_id=4391). And if 86 | you're feeling especially charitable, follow [tpope](http://tpo.pe/) on 87 | [Twitter](http://twitter.com/tpope) and 88 | [GitHub](https://github.com/tpope). 89 | 90 | This pairs great with [sleuth.vim](https://github.com/tpope/vim-sleuth). 91 | 92 | ## License 93 | 94 | Copyright © Tim Pope. Distributed under the same terms as Vim itself. 95 | See `:help license`. 96 | -------------------------------------------------------------------------------- /plugin/sensible.vim: -------------------------------------------------------------------------------- 1 | " sensible.vim - Defaults everyone can agree on 2 | " Maintainer: Tim Pope 3 | " Version: 2.0 4 | 5 | if exists('g:loaded_sensible') || &compatible 6 | finish 7 | else 8 | let g:loaded_sensible = 'yes' 9 | endif 10 | 11 | " Use :help 'option' to see the documentation for the given option. 12 | 13 | " Disable vi compatibility, if for some reason it's on. 14 | if &compatible 15 | set nocompatible 16 | endif 17 | 18 | " Check if an option was set from a file in $HOME. This lets us avoid 19 | " overriding options in the user's vimrc, but still override options in the 20 | " system vimrc. 21 | function! s:MaySet(option) abort 22 | if exists('*execute') 23 | let out = execute('verbose setglobal all ' . a:option . '?') 24 | else 25 | redir => out 26 | silent verbose execute 'setglobal all' a:option . '?' 27 | redir END 28 | endif 29 | return out !~# " \\(\\~[\\/]\\|Lua\\)[^\n]*$" 30 | endfunction 31 | 32 | if s:MaySet('backspace') 33 | set backspace=indent,eol,start 34 | endif 35 | " Disable completing keywords in included files (e.g., #include in C). When 36 | " configured properly, this can result in the slow, recursive scanning of 37 | " hundreds of files of dubious relevance. 38 | set complete-=i 39 | if s:MaySet('smarttab') 40 | set smarttab 41 | endif 42 | 43 | set nrformats-=octal 44 | 45 | " Make the escape key more responsive by decreasing the wait time for an 46 | " escape sequence (e.g., arrow keys). 47 | if !has('nvim') && &ttimeoutlen == -1 48 | set ttimeout 49 | set ttimeoutlen=100 50 | endif 51 | 52 | if has('reltime') && s:MaySet('incsearch') 53 | set incsearch 54 | endif 55 | " Use CTRL-L to clear the highlighting of 'hlsearch' (off by default) and call 56 | " :diffupdate. 57 | if maparg('', 'n') ==# '' 58 | nnoremap :nohlsearch=has('diff')?'diffupdate':'' 59 | endif 60 | 61 | if s:MaySet('laststatus') 62 | set laststatus=2 63 | endif 64 | if s:MaySet('ruler') 65 | set ruler 66 | endif 67 | if s:MaySet('wildmenu') 68 | set wildmenu 69 | endif 70 | 71 | if s:MaySet('scrolloff') 72 | set scrolloff=1 73 | endif 74 | if s:MaySet('sidescroll') && s:MaySet('sidescrolloff') 75 | set sidescroll=1 76 | set sidescrolloff=2 77 | endif 78 | set display+=lastline 79 | if has('patch-7.4.2109') 80 | set display+=truncate 81 | endif 82 | 83 | if s:MaySet('listchars') 84 | set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ 85 | endif 86 | 87 | " Delete comment character when joining commented lines. 88 | if v:version > 703 || v:version == 703 && has("patch541") 89 | set formatoptions+=j 90 | endif 91 | 92 | " Replace the check for a tags file in the parent directory of the current 93 | " file with a check in every ancestor directory. 94 | if has('path_extra') && (',' . &g:tags . ',') =~# ',\./tags,' 95 | setglobal tags-=./tags tags-=./tags; tags^=./tags; 96 | endif 97 | 98 | if s:MaySet('autoread') 99 | set autoread 100 | endif 101 | 102 | if s:MaySet('history') 103 | set history=1000 104 | endif 105 | if s:MaySet('tabpagemax') 106 | set tabpagemax=50 107 | endif 108 | 109 | " Persist g:UPPERCASE variables, used by some plugins, in .viminfo. 110 | if !empty(&viminfo) 111 | set viminfo^=! 112 | endif 113 | " Saving options in session and view files causes more problems than it 114 | " solves, so disable it. 115 | set sessionoptions-=options 116 | set viewoptions-=options 117 | 118 | " Allow color schemes to do bright colors without forcing bold. 119 | if &t_Co == 8 && $TERM !~# '^Eterm' 120 | set t_Co=16 121 | endif 122 | 123 | " If the running Vim lacks support for the Fish shell, use Bash instead. 124 | if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276')) 125 | set shell=/usr/bin/env\ bash 126 | endif 127 | 128 | " Disable a legacy behavior that can break plugin maps. 129 | if has('langmap') && exists('+langremap') && &langremap && s:MaySet('langremap') 130 | set nolangremap 131 | endif 132 | 133 | if !(exists('g:did_load_filetypes') && exists('g:did_load_ftplugin') && exists('g:did_indent_on')) 134 | filetype plugin indent on 135 | endif 136 | if has('syntax') && !exists('g:syntax_on') 137 | syntax enable 138 | endif 139 | 140 | if empty(mapcheck('', 'i')) 141 | inoremap u 142 | endif 143 | if empty(mapcheck('', 'i')) 144 | inoremap u 145 | endif 146 | 147 | " From `:help :DiffOrig`. 148 | if exists(":DiffOrig") != 2 149 | command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ 150 | \ | diffthis | wincmd p | diffthis 151 | endif 152 | 153 | " Correctly highlight $() and other modern affordances in filetype=sh. 154 | if !exists('g:is_posix') && !exists('g:is_bash') && !exists('g:is_kornshell') && !exists('g:is_dash') 155 | let g:is_posix = 1 156 | endif 157 | 158 | " Load matchit.vim, but only if the user hasn't installed a newer version. 159 | if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' 160 | runtime! macros/matchit.vim 161 | endif 162 | 163 | " Enable the :Man command shipped inside Vim's man filetype plugin. 164 | if exists(':Man') != 2 && !exists('g:loaded_man') && &filetype !=? 'man' && !has('nvim') 165 | runtime ftplugin/man.vim 166 | endif 167 | --------------------------------------------------------------------------------