{"id":23284199,"url":"https://github.com/agilecreativity/vim_printer","last_synced_at":"2026-07-06T03:31:11.513Z","repository":{"id":16098212,"uuid":"18843079","full_name":"agilecreativity/vim_printer","owner":"agilecreativity","description":"Quickly print any files in any languages to htmls using the power of Vim","archived":false,"fork":false,"pushed_at":"2018-03-15T03:12:59.000Z","size":1319,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T05:01:58.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agilecreativity.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-16T14:40:19.000Z","updated_at":"2019-12-05T08:26:05.000Z","dependencies_parsed_at":"2022-07-15T23:18:05.770Z","dependency_job_id":null,"html_url":"https://github.com/agilecreativity/vim_printer","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fvim_printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fvim_printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fvim_printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fvim_printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilecreativity","download_url":"https://codeload.github.com/agilecreativity/vim_printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247500476,"owners_count":20948880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-20T01:38:37.961Z","updated_at":"2025-10-28T15:18:34.576Z","avatar_url":"https://github.com/agilecreativity.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## vim_printer\n\n[![Gem Version](https://badge.fury.io/rb/vim_printer.svg)][gem]\n[![Dependency Status](https://gemnasium.com/agilecreativity/vim_printer.png)][gemnasium]\n[![Code Climate](https://codeclimate.com/github/agilecreativity/vim_printer.png)][codeclimate]\n\n[gem]: http://badge.fury.io/rb/vim_printer\n[gemnasium]: https://gemnasium.com/agilecreativity/vim_printer\n[codeclimate]: https://codeclimate.com/github/agilecreativity/vim_printer\n\nBatch print/export files to htmls using the power of Vim. Output will be saved to `vim_printer_#{project_name}.tar.gz` and ready for\nextract and view in your favourite browser.\n\n- Unlimited support for [vim colorschemes][] if enabled, or `default` colorscheme that comes with Vim.\n- Can print any files in any languages that you can open with Vim.\n- Use the power of [Vim][] to print the code without any other tools.\n- Skip any binary files automatically\n\n### Example Outputs:\n\n- The original input using [seoul256.vim][] colorscheme in Vim\n\n![](https://github.com/agilecreativity/vim_printer/raw/master/01-seoul256-input.png)\n\nThe html output as rendered in the browser\n\n![](https://github.com/agilecreativity/vim_printer/raw/master/01-seoul256-output.png)\n\n- The original input using `Tomorrow-Night` colorscheme from [Tomorrow-theme][] in Vim\n\n![](https://github.com/agilecreativity/vim_printer/raw/master/02-Tomorrow-Night-input.png)\n\nThe html output as renderd in the browser\n\n![](https://github.com/agilecreativity/vim_printer/raw/master/02-Tomorrow-Night-output.png)\n\n### Requirements\n\n- [Vim][] - any recent version should be ok.\n\n- Any decent `~/.vimrc` should do\n\n  * There are so many great vim dotfiles in github repos, just search for `dotfiles` keyword:w\n  * [NeoBundle][] is a very good start if you are new to Vim.\n  * If you like you can use [my dotvim][] which is based on the [NeoBundle][].\n  * Use any [vim colorschemes][] if not the `default` colorscheme will be used.\n    My personal favourite are [seoul256.vim][] and [Tomorrow-Theme][]\n\n- Any valid file types that are supported by Vim will produce proper color syntax in the output.\n  * By default Vim supports most of major languages so you should see the proper syntax with color in the output.\n  * On newer language like [Elixir][], you may have to first install [vim-elixir][] to see the proper syntax in the output.\n    If this is not installed then you will get the output but will not have the beautiful color syntax.\n\n### Sample session\n\n- Run with the sample fixture files\n\n```sh\nvim_printer -b test/fixtures -e rb java -r\n```\n\nWill produce the file `vim_printer_fixtures.tar.gz` with the following result on the screen.\n\n```\nFYI: process file 1 of 8 : ./demo1.xxx.rb\nFYI: process file 2 of 8 : ./demo1.yyy.rb\nFYI: process file 3 of 8 : ./demo2.xxx.rb\nFYI: process file 4 of 8 : ./demo2.yyy.rb\nFYI: process file 5 of 8 : ./java/demo3.xxx.java\nFYI: process file 6 of 8 : ./java/demo3.yyy.java\nFYI: process file 7 of 8 : ./java/demo4.xxx.java\nFYI: process file 8 of 8 : ./java/demo4.yyy.java\nYour output file is ./test/fixtures/vim_printer_fixtures.tar.gz\n```\n\n### Usage\n\n- Install the gem for your version of ruby\n\ne.g. for rbenv your session will be something like\n\n```sh\nrbenv local 2.1.2\nrbenv rehash\ngem install vim_printer\n```\n\n- Print any files using the gem\n\n```sh\nvim_printer\n```\n\n- Print any files that you like using the simplest command\n\nThe following command will print out all java, and ruby files recursively\nusing the `solarized` colorscheme.\n\n```sh\nvim_printer --base-dir ./test/fixtures \\\n            --exts rb \\\n            --theme solarized\n```\n\nYour output will be saved to the default `vim_printer_fixtures.tar.gz` in the directory where you run this command.\nTo see the output in your browser just type:\n\n```sh\nmkdir -p ~/Desktop/vim_printer\nmv vim_printer_fixtures.tar.gz ~/Desktop/vim_printer\ncd ~/Desktop/vim_printer\ntar zxvf vim_printer_fixtures.tar.gz\n```\n\n- Print only files that contain the word `xxx` in the title\n\n```sh\nvim_printer --base-dir ./test/fixtures \\\n            --exts java \\\n            --theme solarized \\\n            --n xxx\n```\n\n- To include files that do not have any extension you can use `--non-exts`\n\n```shell\n# To print all ruby files as well as 'Gemfile' or 'Rakefile'\nvim_printer -e ruby -f Gemfile Rakefile -r\n```\n### Advanced Usage\n\nThe new `--command` or `-s` flag can be used to get the input from the list of file.\nAny unix command that can produce the result in the list of file can be used to\ngenerate the input for printing.\n\nMy personal use-cases:\n\n- Print out any files that we changed in the last N git commit\n(Note any binary files or deleted files will skipped automatically)\n\ne.g. Print out any files that were changed in the last 2 commit\n\n```shell\n# Must be run from inside the project directory containging the git project\nvim_printer --command 'git diff --name-only HEAD~2'\n```\n\n- Use list of file from the result of `find` with `grep` command (from inside the project directory)\n\n```shell\nvim_printer --command 'find . -type f -iname \"*.rb\" | grep -v _spec'\n```\n\n### Limitation/Workaround\n\n- The `--base-dir` must be used with the `--command` if the command is not run in the context of current directory.\n\ne.g. Assume that you want to print all of the ruby `*.rb` files from `~/Desktop/project` and you are not currently\ninside the `~/Desktop/project` directory\n\n```\n# Go to home directory\ncd ~\n\n# Note we are not inside the `~/Desktop/project` directory\nvim_printer --command \"find ~/Desktop/project -type f -iname '*.rb'\" --base-dir ~/Desktop/project\n```\n\nWill give the proper links in the generated `index.html` file\n\nBut\n\n```\n# Go to home directory\ncd ~\n\n# Run the command from the home directory\nvim_printer --command \"find ~/Desktop/project -type f -iname '*.rb'\" --base-dir .\n```\nwill produces the invalid links in the generated `index.html` file\n\n### Usage/Synopsys\n\nFor help in using the gem just type `vim_printer` without any parameter\n\n```\nUsage:\n  vim_printer\n\nOptions:\n  -b, [--base-dir=BASE_DIR]                # Base directory\n                                           # Default: . (current directory)\n  -e, [--exts=one two three]               # List of extension to search for\n                                           # e.g. -e rb md\n  -f, [--non-exts=one two three]           # List of file without extension to be included in the result (optional)\n                                           # e.g. -f Gemfile LICENSE\n  -n, [--inc-words=one two three]          # List of word that must be part of the name to be included in the result (optional)\n                                           # If this option is not specified then\n                                           # all files having the extension specified by -e or all file specified by -f will be included\n  -x, [--exc-words=one two three]          # List of words to be excluded from the result if any (optional)\n                                           # Use this option to filter out files that contain some word in the name\n                                           # e.g. -x '_spec' to exclude files that end with '*_spec.rb' in the name\n  -i, [--ignore-case], [--no-ignore-case]  # Match case insensitively apply to both -f, n, and -x options (optional)\n                                           # Default: --ignore-case\n  -r, [--recursive], [--no-recursive]      # Search for files recursively (optional)\n                                           # Default: --recursive\n  -v, [--version]                          # Display version information\n                                           #\n  -t, [--theme=THEME]                      # Vim colorscheme to use (optional)\n                                           # Default: 'default'\n  -c, [--index], [--no-index]              # Generate the index.html file for the result (optional)\n                                           # Default: --index\n  -s, [--command]                          # Use the input file list from the result of the given shell command\n                                           # Note: the command must return the list of file to be valid\n                                           # This option ignore any of the following options -e, -f, -n, -x, -i if specified\n                                           # e.g. --command 'git diff --name-only HEAD~2 | grep -v test'\n                                           # e.g. --command 'find . -type f -iname \"*.rb\" | grep -v test | grep -v _spec'\nPrint files to (x)html using Vim\n\n```\n\n### Customization for output options\n\nYou can customize how the output is produced by using the following configuration.\n\nEdit the file `lib/vim_printer/config/vim_printer.rb` to adjust the options used by\n`:TOhtml` in Vim. (see `:help :TOhtml` from inside Vim for more detail)\n\nThe default settings for the `:TOhtml` are as follow\n\n```ruby\n[\n    \"-c 'let g:html_expand_tabs = 1'\",\n    \"-c 'let g:html_use_css = 1'\",\n    \"-c 'let g:html_no_progress = 1'\",\n    \"-c 'let g:html_number_lines = 0'\",\n    \"-c 'let g:html_use_xhtml = 1'\",\n    \"-c 'let g:html_ignore_folding = 1'\"\n]\n```\n\nFor example, if you like to suppress the line number in the output you will\nneed to use `\"-c 'let g:html_number_lines = 0'\"` which will suppress the\nsetting of `:set number` in Vim.\n\n### Development/Testing\n\n```sh\ngit clone https://github.com/agilecreativity/vim_printer.git\ncd vim_printer\nbundle\n# run default test\nrake\n```\n\n### Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Make sure that you add the tests and ensure that all tests are passed\n5. Push to the branch (`git push origin my-new-feature`)\n6. Create new Pull Request\n\n[NeoBundle]: https://github.com/Shougo/neobundle.vim\n[Vim]: https://www.vim.org\n[my dotvim]: https://github.com/agilecreativity/dotvim\n[Elixir]: http://elixir-lang.org\n[vim-elixir]: https://github.com/elixir-lang/vim-elixir\n[vim colorschemes]: https://github.com/flazz/vim-colorschemes/tree/master/colors\n[seoul256.vim]: https://github.com/junegunn/seoul256.vim\n[Tomorrow-theme]: https://github.com/ChrisKempson/Tomorrow-Theme\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fvim_printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilecreativity%2Fvim_printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fvim_printer/lists"}