Software Engineering, Web Development and 3D Design

Inserting Code Samples Into PowerPoint

Displaying code in PowerPoint seems to be a pain. I came up with a simple way to get syntax highlighting in powerpoints using GitHub Gist. There may be better ways of doing this, but I found this way to be the most convenient for me on a Mac:

  1. Copy code from terminal (or whatever application you are viewing it in) and paste it into a GitHub Gist.
  2. Save gist and copy code out of the gist and into TextEdit (make sure TextEdit is in rich text mode before you paste in your code).
  3. Copy from TextEdit into your powerpoint and choose “keep formatting” from the paste icon that appears.

I found that creating a new text box before pasting in the code is a good idea as it allows you to control the font size of the code separate from everything else on the slide. It also allows you to set a background color for the code sample.

I know there are other ways of doing this out there, but I thought I would post my method as it’s very simple and uses GitHub’s syntax highlighting. If you have a better way of doing this I would love to hear about it!

Working With HTML in Vim

I discovered another Vim command this week that made working with raw HTML much easier and figured I would share it.

The command sequence is dit. Focus the cursor over an HTML tag and in normal mode type dit. The contents of the tag will be deleted and the empty tag will remain. The cursor will be positioned at the end of the first tag. In order to insert more content all you need to do is type i and begin entering the new contents of the tag. This command comes in very handy when having to make lots of manual changes to an HTML document.

Example: Before: Title


When working with raw HTML it’s helpful to have the markup indented so you can easily see parent/child and sibling relationships. In your .vimrc you will want to have a line turning on the file type indent on: filetype indent on. Whenever you open up a html file or paste html into an empty buffer make sure the file type is set by running :set ft in normal mode. Vim should print filetype=html as the result. If it doesn’t you want to correct the file type before proceeding. Then select all the markup and simply type = in normal mode. The HTML should be nicely indented with the settings you specified in your .vimrc or filetype file. Note that on large files this can take a while (sometimes almost a minute).

If you have any other vim commands that you frequently use when working with Vim I would love to hear about them!