sponsor Vim development Vim logo Vim Book Ad

vimcat : print syntax highlighted file to terminal

 script karma  Rating 507/177, Downloaded by 11606  Comments, bugs, improvements  Vim wiki

created by
Rafael Kitover
 
script type
utility
 
description
This script will convert a file to a highlighted version using ANSI escape codes and print it to your terminal, like cat only with colors.

This script is part of the vimpager project, which itself is available on vim.org here:

http://www.vim.org/scripts/script.php?script_id=1723

The project is hosted on GitHub, where you can file issues and submit pull requests:

https://github.com/rkitover/vimpager

ACKNOWLEDGEMENTS:

Most of the code in this script is not mine, I only fixed some minor OS compatibility issues.

The following people are responsible for this functionality:

Original vim script for highlighting with ANSI codes, AnsiHighlight by:

Matthew Wozniski (mjw@drexel.edu)

Original conversion to shell script by:

Magnus Woldrich: https://github.com/trapd00r/utils/blob/master/_v

Fixes to the highlighting code to make the utility actually usable (and not bleed the background color etc.) by:

krijesta: Chris Chambers <krijesta@google.com>
 
install details
chmod +x vimcat
mkdir ~/bin
mv vimcat ~/bin

add $HOME/bin to your PATH in your ~/.bashrc or other shell startup file.

# COMMAND LINE OPTIONS

## -c cmd

Run a vim command after opening the file. Multiple -c arguments are
supported.

## --cmd cmd

Run a vim command when entering vim before anything else. Multiple --cmd
arguments are supported.

## -u vimrc

Use an alternate .vimrc or .vimcatrc.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vimcat 2.06 2015-06-28 7.0 Rafael Kitover * Solaris compatibility fixes
* remove array syntax for compatibility with more shells #118
vimcat 2.0 2015-04-29 7.0 Rafael Kitover * support multiple -c and --cmd options, as
  well as the -u option
* support MSYS2
vimcat 1.8.9 2014-05-25 7.0 Rafael Kitover * security enhancements (snordhausen: Stefan Nordhausen) #78
* exit on empty file instead of hanging (mapeiqi88) #80
vimcat 1.8.8 2014-04-07 7.0 Rafael Kitover * don't clobber user's PATH (mayersj1: Steve Mayer)  #77
vimcat 1.8.3 2013-12-23 7.0 Rafael Kitover * manpage for vimcat available on github (aroig: Abdo Roig-Maranges)
* add -c option for extra vim command (aroig: Abdo Roig-Maranges)
* pass through if not on a tty (dfechner: Dustin Fechner)
vimcat 1.7.9 2013-02-10 7.0 Rafael Kitover * reset fg color if no fg color is set (GitHub #56) (krijesta)
* use #!/usr/bin/env bash as the shebang
vimcat 1.7.8 2012-12-31 7.0 Rafael Kitover * change shebang from /bin/sh to /bin/bash, as it's a bash script (GitHub Issue #53)
* use aixterm escapes for light non-bold colors (aroig: Abdó Roig-Maranges)
* reads ~/.vimcatrc if it exist for config (aroig: Abdó Roig-Maranges)
* disables writing to viminfo (aroig: Abdó Roig-Maranges)
* allow vimcat to read from stdin (krijesta: Chris Chambers)
vimcat 1.7.7 2012-11-26 7.0 Rafael Kitover Initial upload
ip used for rating: 44.220.184.63

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github