├── README.asciidoc ├── doc └── lotr.txt ├── plugin └── lotr.vim └── syntax └── lotr.vim /README.asciidoc: -------------------------------------------------------------------------------- 1 | LOTR 2 | ---- 3 | 4 | __Lord of the Regs__ 5 | 6 | TIP: If you like vim-lotr and want to share the W00t!, I'm grateful for 7 | https://www.gittip.com/bairuidahu/[tips] or 8 | http://of-vim-and-vigor.blogspot.com/[beverages]. 9 | 10 | LOTR displays a persistent view of your Vim `:registers` in a sidebar window. 11 | 12 | == Commands 13 | 14 | * `:LOTROpen` 15 | * `:LOTRClose` 16 | * `:LOTRToggle` also available through `LOTRToggle` which is mapped to `cr` by default. 17 | 18 | == Within the LOTR window: 19 | 20 | * `q` closes the LOTR window 21 | * `` toggles zoom mode 22 | * `` returns to the prior window 23 | 24 | == YankStack 25 | 26 | LOTR now shows the :Yanks list from the YankStack plugin. + 27 | Disable this by adding this line to your `~/.vimrc`: 28 | 29 | let g:lotr_yankstack = 0 30 | 31 | -------------------------------------------------------------------------------- /doc/lotr.txt: -------------------------------------------------------------------------------- 1 | *lotr.txt* Lord of the Regs 2 | 3 | 4 | VIM REFERENCE MANUAL by Barry Arthur 5 | 6 | 7 | Help on using lotr *lotr* 8 | 9 | 1. Introduction |lotr-intro| 10 | 2. Configuration |lotr-configuration| 11 | 3. Commands |lotr-commands| 12 | 4. LOTR Window Commands |lotr-window-commands| 13 | 14 | ============================================================================== 15 | 1. INTRODUCTION *lotr-intro* 16 | 17 | LOTR -- Lord of the Regs -- A persistent view of :registers in a sidebar window. 18 | 19 | ============================================================================== 20 | 2. CONFIGURATION *lotr-configuration* 21 | 22 | These options can be set in your |$MYVIMRC| to modify the behaviour of LOTR: 23 | 24 | |'lotr_position'| Position the LOTR window (left, right, top, bottom) 25 | |'lotr_winsize'| Width or height of the LOTR window 26 | |'lotr_expand'| Force GVim to widen if necessary to accommodate LOTR 27 | |'lotr_yankstack'| Show the :Yanks list from the YankStack plugin 28 | 29 | ------------------------------------------------------------------------------ 30 | *'lotr_position'* 31 | Values: string (left, right, top, bottom) ~ 32 | Default: right ~ 33 | 34 | ------------------------------------------------------------------------------ 35 | *'lotr_winsize'* 36 | Values: number ~ 37 | Default: 25 ~ 38 | 39 | ------------------------------------------------------------------------------ 40 | *'lotr_expand'* 41 | Values: boolean ~ 42 | Default: 0 ~ 43 | 44 | By default the LOTR window will not cause GVim to resize to accommodate it. 45 | 46 | ------------------------------------------------------------------------------ 47 | *'lotr_focus_on_open'* 48 | Values: boolean ~ 49 | Default: 0 ~ 50 | 51 | By default the LOTR window will not take focus when opened. 52 | 53 | ------------------------------------------------------------------------------ 54 | *'lotr_map_keys'* 55 | Values: boolean ~ 56 | Default: 1 ~ 57 | 58 | By default LOTR will add key maps. 59 | 60 | ------------------------------------------------------------------------------ 61 | *'lotr_yankstack'* 62 | Values: boolean ~ 63 | Default: 1 ~ 64 | 65 | If installed, LOTR will show the YankStack list as shown by the :Yanks command. 66 | 67 | ============================================================================== 68 | 3. COMMANDS *lotr-commands* 69 | 70 | The following commands are available: 71 | 72 | `:LOTROpen` Open the LOTR window 73 | 74 | `:LOTRClose` Close the LOTR window 75 | 76 | `:LOTRToggle` Toggle the open/close state of the LOTR window 77 | 78 | 79 | The `:LOTRToggle` command is also available through `LOTRToggle` 80 | which is mapped to `cr` by default. If `g:lotr_map_keys` is set 81 | to 0 then the map will not be added. You can change this by adding a line 82 | like this to your |$MYVIMRC|: 83 | > 84 | nmap r LOTRToggle 85 | < 86 | 87 | 88 | ============================================================================== 89 | 4. LOTR WINDOW COMMANDS *lotr-window-commands* 90 | 91 | From within the LOTR window: 92 | 93 | `` Jumps back to the prior window (|wincmd| p) 94 | `` Toggles zoom mode 95 | `q` Closes the LOTR window 96 | 97 | 98 | Template From: https://github.com/dahu/Area-41/ 99 | vim:tw=78:ts=8:ft=help:norl: 100 | -------------------------------------------------------------------------------- /plugin/lotr.vim: -------------------------------------------------------------------------------- 1 | "" ============================================================================ 2 | " File: lotr.vim 3 | " Description: A persistent view of :registers in Vim 4 | " Authors: Barry Arthur 5 | " Licence: Vim licence 6 | " Website: http://dahu.github.com/vim-lotr/ 7 | " Note: This plugin was heavily inspired by the 'Tagbar' plugin by 8 | " Jan Larres and uses great gobs of code from it. 9 | " 10 | " Original taglist copyright notice: 11 | " Permission is hereby granted to use and distribute this code, 12 | " with or without modifications, provided that this copyright 13 | " notice is copied with it. Like anything else that's free, 14 | " taglist.vim is provided *as is* and comes with no warranty of 15 | " any kind, either expressed or implied. In no event will the 16 | " copyright holder be liable for any damamges resulting from the 17 | " use of this software. 18 | " ============================================================================ 19 | 20 | if &cp || exists('g:loaded_lotr') 21 | finish 22 | endif 23 | 24 | " Initialization {{{1 25 | 26 | " Basic init {{{2 27 | 28 | if v:version < 702 29 | echomsg 'LOTR: Vim version is too old, LOTR requires at least 7.2' 30 | finish 31 | endif 32 | 33 | let g:loaded_lotr = 1 34 | 35 | if !exists('g:lotr_left') 36 | let g:lotr_left = 0 37 | endif 38 | 39 | if !exists('g:lotr_position') 40 | let g:lotr_position = g:lotr_left ? 'left' : 'right' 41 | endif 42 | 43 | if !exists('g:lotr_width') 44 | let g:lotr_width = 0 45 | endif 46 | 47 | if !exists('g:lotr_winsize') 48 | let g:lotr_winsize = g:lotr_width ? g:lotr_width : 25 49 | endif 50 | 51 | if !exists('g:lotr_expand') 52 | let g:lotr_expand = 0 53 | endif 54 | 55 | if !exists('g:lotr_focus_on_open') 56 | let g:lotr_focus_on_open = 0 57 | endif 58 | 59 | if !exists('g:lotr_map_keys') 60 | let g:lotr_map_keys = 1 61 | endif 62 | 63 | if !exists('g:lotr_yankstack') 64 | let g:lotr_yankstack = 1 65 | endif 66 | 67 | let s:autocommands_done = 0 68 | let s:source_autocommands_done = 0 69 | let s:window_expanded = 0 70 | 71 | " Registers {{{2 72 | function! LOTR_Regs() 73 | let core_regs = ['"', '-', '*', '+', '/'] 74 | let regs = {} 75 | let reglist = [] 76 | 77 | for reg in extend(extend(range(10), core_regs), map(range(26), 'nr2char(char2nr("a") + v:val)')) 78 | call extend(regs, {reg : getreg(reg)}) 79 | endfor 80 | 81 | for reg in core_regs 82 | call add(reglist, reg . ' ' . substitute(regs[reg], '\n', '^J', 'g')) 83 | endfor 84 | 85 | call add(reglist, '') 86 | 87 | for reg in range(10) 88 | call add(reglist, reg . ' ' . substitute(regs[reg], '\n', '^J', 'g')) 89 | endfor 90 | 91 | call add(reglist, '') 92 | 93 | for regn in range(26) 94 | let reg = nr2char(char2nr('a') + regn) 95 | if (has_key(regs, reg)) && (regs[reg] != '') 96 | call add(reglist, reg . ' ' . substitute(regs[reg], '\n', '^J', 'g')) 97 | endif 98 | endfor 99 | 100 | if g:lotr_yankstack && exists(':Yanks') 101 | redir => yankstack_regs 102 | silent! Yanks 103 | redir END 104 | 105 | call add(reglist, '') 106 | 107 | for regline in split(yankstack_regs, "\n")[1:] 108 | let [reg; text] = matchlist(regline, '\(^\d\+\)\%(\s\+\(.*\)\)\?')[1:2] 109 | call add(reglist, printf("%2d", reg) . ' ' . substitute(text[0], '\n', '^J', 'g')) 110 | endfor 111 | endif 112 | 113 | return reglist 114 | endfunction 115 | 116 | function! s:CreateAutocommands() "{{{2 117 | augroup LOTR_AutoCmds 118 | autocmd! 119 | autocmd BufEnter __LOTR__ nested call s:QuitIfOnlyWindow() 120 | autocmd BufUnload __LOTR__ call s:CleanUp() 121 | autocmd CursorHold,CursorMoved * call s:AutoUpdate() 122 | augroup END 123 | 124 | let s:autocommands_done = 1 125 | endfunction 126 | 127 | function! s:MapKeys() "{{{2 128 | nnoremap