How to enable syntax highlighting for Strace output in Vim


Strace output can be written to a log file by using the -o option. This output is typically verbose and I find it helpful if the editor can apply syntax highlighting on it. This gives the system call, its parameters and its output different colors and makes it easy to understand the log.

Vim has support for syntax highlighting of strace output. You can see this in the /usr/share/vim/vim74/syntax/strace.vim file. Vim tries to detect if the file is strace output by looking for an execve or libc pattern in the first line. This logic can be seen in its /usr/share/vim/vim74/scripts.vim file. I have never seen these patterns in the first line in my strace output.

Since Vim does not automatically detect my strace output file, I enable it explicitly using the command: :set filetype=strace

Another trick is to output strace to a file of particular extension, say .strace and look for that file extension to set the strace filetype automatically. If you want this, then add this line to your .vimrc:

autocmd BufRead,BufNewFile *.strace set filetype=strace

Tried with: Vim 7.4, Strace 4.8-1 and Ubuntu 14.04


2 thoughts on “How to enable syntax highlighting for Strace output in Vim

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.