├── .gitignore ├── LICENSE.md ├── README.md ├── doc └── vim-pager.txt └── plugin └── pager.vim /.gitignore: -------------------------------------------------------------------------------- 1 | test/.env 2 | doc/tags 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | vim-gita License 2 | ============================================================================== 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2015 Alisue, hashnote.net 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-pager 2 | =============================================================================== 3 | *vim-pager* is plugin to use Vim as a PAGER. 4 | See [lambdalisue/vim-manpager](https://github.com/lambdalisue/vim-manpager) for MANPAGER. 5 | 6 | ![Screencast](http://g.recordit.co/pD8mPPxt2n.gif) 7 | 8 | Install 9 | ------------------------------------------------------------------------------- 10 | 11 | ```vim 12 | " Vundle.vim 13 | Plugin 'lambdalisue/vim-pager' 14 | 15 | " neobundle.vim 16 | NeoBundle 'lambdalisue/vim-pager' 17 | 18 | " neobundle.vim (Lazy) 19 | NeoBundleLazy 'lambdalisue/vim-pager', { 20 | \ 'autoload': { 21 | \ 'commands': 'PAGER', 22 | \}} 23 | ``` 24 | 25 | If you want to convert ANSI sequence into Vim's highlight, checkout the following 26 | plugins. vim-pager will automatically call `:AnsiEsc` command when `:PAGER` 27 | command is called. 28 | 29 | - [vim-scripts/AnsiEsc.vim](https://github.com/vim-scripts/AnsiEsc.vim) 30 | - [powerman/vim-plugin-AnsiEsc](https://github.com/powerman/vim-plugin-AnsiEsc) (An improved AnsiEsc.vim) 31 | 32 | Usage 33 | ------------------------------------------------------------------------------- 34 | 35 | ``` 36 | $ export PAGER="vim -c PAGER -" 37 | $ git log 38 | ``` 39 | 40 | 41 | License 42 | ------------------------------------------------------------------------------- 43 | The MIT License (MIT) 44 | 45 | Copyright (c) 2015 Alisue, hashnote.net 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is 52 | furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in 55 | all copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 63 | THE SOFTWARE. 64 | -------------------------------------------------------------------------------- /doc/vim-pager.txt: -------------------------------------------------------------------------------- 1 | *vim-pager.txt* A plugin to use Vim as a PAGER 2 | 3 | Version: 0.1.0 4 | Author: Alisue *vim-pager-author* 5 | Support: Vim 7.4 and above 6 | License: MIT license 7 | 8 | Copyright (c) 2014 Alisue, hashnote.net 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining 11 | a copy of this software and associated documentation files 12 | (the "Software"), to deal in the Software without restriction, 13 | including without limitation the rights to use, copy, modify, merge, 14 | publish, distribute, sublicense, and/or sell copies of the Software, 15 | and to permit persons to whom the Software is furnished to do so, 16 | subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be 19 | included in all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 25 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | 29 | ============================================================================= 30 | CONTENTS *vim-pager-contents* 31 | 32 | Introduction |vim-pager-introduction| 33 | Install |vim-pager-install| 34 | Recommends |vim-pager-install-recommends| 35 | Usage |vim-pager-usage| 36 | Interface |vim-pager-interface| 37 | Commands |vim-pager-interface-commands| 38 | Variables |vim-pager-interface-variables| 39 | 40 | ============================================================================== 41 | INTRODUCTION *vim-pager-introduction* 42 | 43 | Use Vim as a PAGER 44 | See lambdalisue/vim-manpager for MANPAGER 45 | 46 | ============================================================================== 47 | INSTALL *vim-pager-install* 48 | 49 | The repository (https://github.com/lambdalisue/vim-pager) follow a standard 50 | directory structure thus you can use Vundle.vim, neobundle.vim, or other vim 51 | plugin manager to install |vim-pager| like: 52 | > 53 | " Vundle.vim 54 | Plugin 'lambdalisue/vim-pager' 55 | 56 | " neobundle.vim 57 | NeoBundle 'lambdalisue/vim-pager' 58 | 59 | " neobundle.vim (Lazy) 60 | NeoBundleLazy 'lambdalisue/vim-pager', { 61 | \ 'autoload': { 62 | \ 'commands': 'PAGER', 63 | \}} 64 | < 65 | If you are not using any vim plugin manager, you can copy the repository to 66 | your $VIM directory to enable the plugin. 67 | 68 | ------------------------------------------------------------------------------ 69 | RECOMMENDS *vim-pager-install-recommends* 70 | 71 | vim-pager does not provide a way to convert the ANSI escape sequence into Vim 72 | highlight without external dependencies. 73 | If you prefer to highlight text rather than just remove, install 74 | vim-scripts/AnsiEsc.vim or powerman/vim-plugin-AnsiEsc. 75 | vim-pager automatically call :AnsiEsc command when :PAGER command is called. 76 | 77 | 78 | ============================================================================== 79 | USAGE *vim-pager-usage* 80 | 81 | Add MANPAGER environment variable as 82 | > 83 | $ export PAGER="vim -c PAGER -" 84 | < 85 | Then 'man' command will use Vim as a PAGER. 86 | 87 | 88 | ============================================================================== 89 | INTERFACE *vim-pager-interface* 90 | 91 | ------------------------------------------------------------------------------ 92 | COMMANDS *vim-pager-interface-commands* 93 | 94 | :PAGER *:PAGER* 95 | 96 | Enable PAGER mode on the current buffer. 97 | 98 | ------------------------------------------------------------------------------ 99 | VARIABLES *vim-pager-interface-variables* 100 | 101 | g:pager#use_AnsiEsc *g:pager#use_AnsiEsc* 102 | 103 | Use vim-scripts/AnsiEsc.vim (or powerman/vim-plugin-AnsiEsc) to remove 104 | ANSI sequences to enable ANSI highlight. 105 | Default 1. 106 | 107 | vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl 108 | -------------------------------------------------------------------------------- /plugin/pager.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo 2 | set cpo&vim 3 | 4 | function! s:remove_ansi_sequences() abort " {{{ 5 | let saved_modifiable = &l:modifiable 6 | let saved_readonly = &l:readonly 7 | let saved_modified = &l:modified 8 | setl modifiable noreadonly 9 | let saved_pos = getpos('.') 10 | keepjumps :%s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge 11 | call setpos('.', saved_pos) 12 | let &l:modifiable = saved_modifiable 13 | let &l:readonly = saved_readonly 14 | let &l:modified = saved_modified 15 | endfunction " }}} 16 | 17 | function! pager#enable() abort " {{{ 18 | if g:pager#use_AnsiEsc && exists(':AnsiEsc') 19 | AnsiEsc 20 | else 21 | call s:remove_ansi_sequences() 22 | endif 23 | setlocal tabstop=8 24 | setlocal nolist nospell nocursorline 25 | setlocal readonly nomodifiable 26 | setlocal nomodified 27 | nnoremap (pager-close) :q 28 | nmap q (pager-close) 29 | endfunction " }}} 30 | 31 | command! -nargs=0 PAGER call pager#enable() 32 | 33 | let g:pager#use_AnsiEsc = get(g:, 'pager#use_AnsiEsc', 1) 34 | 35 | let &cpo = s:save_cpo 36 | " vim:set et ts=2 sts=2 sw=2 tw=0 fdm=marker: 37 | --------------------------------------------------------------------------------