Posts tagged with vim

Export syntax-highlighted pdf files from vim

If you want to export from vim to a pdf file with syntax highlighting, hardcopy does not seem to use the correct syntax highlighting file. Or rather, it uses...

Making vim display italicised text

To make vim display italicised text, see this wonderful blog entry. Essentially, we need to manually map the escape sequences to the keywords sitm and ritm, ...

PEP8-style indentation in vim

How do you automatically get vim to do PEP8-style indentation for python code? Look up this blog post which references this vim script. It has also been adde...

modeline needs to be set for it to work

Note that in order for vim modelines to work, you must have the ‘modeline’ option set, i.e. :set modeline. Do a :help modeline for more info.

Using ASCII codes in vim

To insert characters with a certain ascii code in vim, use <C-v><code>. For example, <C-v>178 will print the squared symbol. I think only t...

Open binary files in vim

To open binary files in a readable format, use vim -b. A more complex tool is xxd. Look at this link or man xxd for more info.

Vim search register

You can substitute the last search pattern in vim either by omitting the search pattern in the :%s command, or by inserting the contents of the search regist...

Exporting to pdf from vim

Export a vim file in whole or in part to postscript using :hardcopy >file.ps. Then use ps2pdf <file.ps> to convert to pdf.

Word count in vim

Use g<C-g> to find the word count of a document. Also works in visual mode.

Vim modelines

If vim does not detect a filetype correctly, then you can add a modeline at the top of the file (first or second line, I think), which tells vim the filetype...