From: AJ ONeal Date: Mon, 15 Mar 2021 19:40:58 +0000 (+0000) Subject: add vim-viminfo X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=68a56df529935a303c6aa421fe11baa92f90d750;p=webi-installers%2F.git add vim-viminfo --- diff --git a/vim-viminfo/README.md b/vim-viminfo/README.md new file mode 100644 index 0000000..b4d573a --- /dev/null +++ b/vim-viminfo/README.md @@ -0,0 +1,45 @@ +--- +title: vim-viminfo +homepage: https://webinstall.dev/vim-viminfo +tagline: | + viminfo keeps track of Vim's state when switching between files +--- + +To update (replacing the current version) run `webi vim-viminfo`. + +## Cheat Sheet + +> ~/.viminfo stores cursor position, copy and paste buffers, command history, +> and a few other goodies. The defaults aren't always good, and should be +> tweaked. + +In an age where we have terabytes of storage (rather than kilobytes of storage), +it makes sense to bump the size of Vim's copy buffers to match the full size of +largest code file you're likely to come across, and somewhere between several +hours and a few days worth of history. + +This one-line plugin does just that. + +### How to install manually + +Create the file `~/.vim/plugins/viminfo.vim`. Add the same contents as +. + +That will look something like this: + +```vim +" Tell vim to remember certain things when we exit +" '100 : marks will be remembered for up to 100 previously edited files +" "20000: will save up to 20,000 lines for each register +" :200 : up to 200 lines of command-line history will be remembered +" % : saves and restores the buffer list +" n... : where to save the viminfo files +set viminfo='100,\"20000,:200,%,n~/.viminfo +``` + +Then `~/.vimrc` should be updated to include it: + +```vim +" viminfo: reasonable defaults from webinstall.dev/vim-viminfo +source ~/.vim/plugins/viminfo.vim +``` diff --git a/vim-viminfo/install.sh b/vim-viminfo/install.sh new file mode 100644 index 0000000..6c80856 --- /dev/null +++ b/vim-viminfo/install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +function __init_vim_viminfo() { + set -e + set -u + + mkdir -p "$HOME/.vim/plugins" + rm -rf "$HOME/.vim/plugins/viminfo.vim" + + echo "" + + if [ ! -e "$HOME/.vimrc" ]; then + touch "$HOME/.vimrc" + fi + + if ! [ -f "$HOME/.vim/plugins/viminfo.vim" ]; then + mkdir -p ~/.vim/plugins + WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"} + curl -fsS -o ~/.vim/plugins/viminfo.vim "$WEBI_HOST/packages/vim-viminfo/viminfo.vim" + fi + + if ! grep 'source.*plugins.viminfo.vim' -r ~/.vimrc > /dev/null 2> /dev/null; then + set +e + mkdir -p ~/.vim/plugins + printf '\n" Vim Info: reasonable defaults (buffers, history, etc) from webinstall.dev/vim-viminfo\n' >> ~/.vimrc + printf 'source ~/.vim/plugins/viminfo.vim\n' >> ~/.vimrc + set -e + + echo "added ~/.vim/plugins/viminfo.vim" + echo "updated ~/.vimrc with 'source ~/.vim/plugins/viminfo.vim'" + echo "" + fi + + echo "vim-info enabled with reasonable defaults" +} + +__init_vim_viminfo diff --git a/vim-viminfo/viminfo.vim b/vim-viminfo/viminfo.vim new file mode 100644 index 0000000..51d37f5 --- /dev/null +++ b/vim-viminfo/viminfo.vim @@ -0,0 +1,7 @@ +" Tell vim to remember certain things when we exit +" '100 : marks will be remembered for up to 100 previously edited files +" "20000: will save up to 20,000 lines for each register +" :200 : up to 200 lines of command-line history will be remembered +" % : saves and restores the buffer list +" n... : where to save the viminfo files +set viminfo='100,\"20000,:200,%,n~/.viminfo