Skip to content

Instantly share code, notes, and snippets.

" badfmt.vim
" Tasks
" [ ] BadFmtOn and BadFmtOff commands. Let user turn it on.
" [ ] globals -> script local and other plugin infrastructure
" This plugin highlights:
" incorrect use of tabs or spaces;
" incorrect indentation size when using spaces;
" excessively long lines;
@adscriven
adscriven / basicsettings.vim
Last active March 1, 2017 20:11
Vim settings: a basic starting point.
" basicsettings.vim -- a starting point for configuring Vim.
" Adjust 'shiftwidth' and 'expandtab' to taste.
" Don't copy and paste this file without reading the documentation for
" all the options, e.g. :help 'shiftwidth', and understanding what they
" do.
" Indentation
set autoindent backspace=2 shiftwidth=4 softtabstop=-1 expandtab shiftround
@adscriven
adscriven / guessindent.vim
Last active February 22, 2020 23:32
Vim: guess indentation
" guessindent.vim -- Guess indentation settings.
" [ ] Don't match continuation lines
" This works better for code rather than for arbitrarily formatted files
" such as the help files, though it sometimes gets those right too. If
" somebody has edited with `set noet ts=4` in a file where `set et sw=4`
" should be used, there's no easy way to detect that. You'll probably
" get ts=8 in that situation, but the file will need fixing anyway.
@adscriven
adscriven / macrorepeat.vim
Last active June 14, 2018 13:26
Repeat macros with dot.
" File: macrorepeat.vim -- Vim global plugin
" Description: Repeat macro recordings and ex commands with dot.
" Last change: 2017-06-16 Fri
" Maintainer: Antony Scriven <[email protected]>
" Licence: This file is placed in the public domain.
"
" Installation: copy to $HOME/.vim/plugin (Unix)
" $HOME/vimfiles/plugin (Windows)
"
" Features:
@adscriven
adscriven / fileage.vim
Last active May 22, 2018 12:49
Convert time in seconds to human-readable approximate age.
" fileage.vim
" Public domain.
" Usage: :echo Age(time_in_secs, 0)
" Useful in e.g. statusline, but don't use as is: cache
" the age of the file on bufread,bufwrite if you don't want
" to slow things down.
" secs, mins, hours, days, weeks, months, years
@adscriven
adscriven / findfile.vim
Last active September 13, 2020 01:08
Interactive file search (Vim)
" Way out of date now ...
" findfile.vim -- interactive file search
" Experimental; caveat emptor.
" Documentation is at the end.
" Public Domain.
let s:cpo = &cpo
set cpo&vim
@adscriven
adscriven / devdocs.md
Last active April 28, 2018 18:37 — forked from romainl/devdocs.md
Look up keyword on http://devdocs.io from Vim

Look up keyword on http://devdocs.io from Vim

Use :DD without argument to look up the word under the cursor, scoped with the current filetype:

:DD

Use :DD keyword to look up the given keyword, scoped with the current filetype:

:DD Map
" vertregion.vim -- jump to the start and end of vertical regions
" SUMMARY
" Allow the cursor to move to the start or end of a vertical region of
" text. If you are familiar with <C-Up> and <C-Down> in Microsoft
" Excel to move to the edge of a data region, this will feel natural.
" INSTALLATION
" Chuck it in ~/.vim/plugin
@adscriven
adscriven / sessions.vim
Last active May 4, 2018 06:26
Define :SessionRestore and :SessionSave commands for Vim.
" sessions.vim -- Define :SessionSave and :SessionRestore.
" SUMMARY
" $ mkdir ~/.vim/session
" :SessionSave save the current session
" :SessionSave {name} save a session as g:sessions_dir/{name}
" :SessionRestore restore the current session
" :SessionRestore {name} restore the session from g:sessions_dir/{name}
"
" There is tab completion for {name}.
" From:
" https://github.com/igemnace/vim-config/blob/master/cfg/plugin/quick-buffer.vim
" original problem: :B command that extends :b such that I don't have to hit *
function! QuickBuffer(pattern) abort
redraw
let p = substitute(a:pattern, '\s\+$', '', '')
if empty(p)
call feedkeys(":B \<C-d>")
return