Posts Tagged ‘code demo’

How to set up the Windows Command Prompt for code demos

In this post I will share a few simple things you can do to set up your Command Window to help ensure a smooth code demo.

  • Change font size and colors
  • Set up the properties for copy and paste
  • Useful commands and keyboard shortcuts

Change the font size and colors

The default colors and font sizes are designed for someone working at their computer and may not provide good visibility when using a projector to display code to a larger audience.

Default appearance of command window

Default appearance of Command Window

You can edit the properties of the command window to change the font and colors.

Right click on the title bar of the window and select Properties.

Accessing properties menu on

Accessing properties menu on Command Window

  1. Select the Font tab.
  2. Increase the Size
  3. Select Bold fonts
Command Window Font Properties

Font Properties

I recommend leaving the font to Consolas, it is a good font choice for code demonstrations. For more tips on font selection see my post “How to rock a code demo – selecting your font”

You may also want to change the colour scheme, darker fonts on lighter colors can be easier to read in a well lit room.

  1. Select the Colors tab
  2. Set the Screen Text color
  3. Set the Screen Background color
Command Window color properties

Color properties

The end result is easier to read commands.

Command window appearance after changing font and color properties

Updated Command Window appearance

Set up the properties for copy and paste

Ah yes, the joys of copy and paste in the command window. Windows 10 brought some great improvements to the command window for fans of copy and paste (which is basically everyone!)

There are a few properties you probably want to ensure you have enabled. Just right click on the title bar and select Properties | Options

Command Window Options Property window

Command Window Options

  • QuickEdit Mode – allows you to use the left mouse button to highlight and select text in the Command prompt window and right click to select the text, then the next time you right click in the window it will paste the text. If you have Quick Edit mode disabled then you get
  • Enable Ctrl key shortcuts – allows you to use CTRL+C and CTRL+V to copy and paste
  • Filter clipboard contents on paste – will remove tabs, and convert smart quotes to regular quotes.
  • Enable line wrapping selection – Allows you to easily copy a command that wraps over multiple lines

Check out the post “How to copy and paste in cmd” by Baz Edwards for a more complete list of copy and paste options, or check out the post “the new features of the Windows 10 command prompt” by Martin Brinkmann for a more complete list of all the Command Window properties.

Useful commands and keyboard shortcuts

Knowing a few commands and keyboard shortcuts can make you look like a pro!

  • cls  clear the screen
  • Up arrow  scroll through previously issued commands
  • Right arrow recreate the previous command character by character
  • Toggle between full screen and windowed mode
  • Enter/Exit Mark mode – When you are in mark mode you can use the arrow keys to move your cursor around the window

34 Useful Keyboard Shortcuts for the Windows Command Prompt by @wjglenn if you want more keyboard shortcuts.

When I published this post, the most current Windows Command documentation was at Docs.Microsoft.com . However, the documentation page has a warning indicating that they are not maintaining the page, so it is possible there have been updates since this page was last updated.

How to rock a code demo – Selecting your font

FontChoicesIn this post I will provide tips on how to select a suitable font for code demonstrations.

One key factor in success when delivering a code demonstration is the visibility of your code. The font you use affects how easily I can read your code.

In this post I’ll discuss four characteristics to consider when selecting the font for your code:

  • Character differentiation
  • Character width
  • Monospace/Proportional
  • Ligatures

Character differentiation

The first thing you need to check is whether your font clearly differentiates different characters. A good test is to compare

  • The number 0 from the letter ‘O’
  • The number 1 from a lowercase letter ‘L’ or an uppercase letter ‘i’.

Variable names and assignments, API Keys, file paths, and URLs can contain a variety of characters. Selecting a font with good character differentiation can help avoid confusion when walking through your code.

Below is a character comparison for a variety of fonts you might find pre-installed in your code editors. Many code editors default to Consolas which has excellent character differentiation.

FontsCharacterDifferentiation

Character width

Another factor to consider is whether how much horizontal space is taken up by a single character. Ideally you want the code to fit on a single line without scrolling, so a narrower font may make it easier to display your code.

All the samples in the table below are the same font size.

At first glance Verdana and Segoe UI look similar, but Segoe is a narrower font so might be a better choice. You do need to be careful not to pick a font so narrow it becomes difficult to read such as TW Cen MT Condensed.

FontWidth

Monospaced/proportional fonts

General consensus is that you should always use a monospace (proportional) font for code. Monospace fonts use the same amount of horizontal space for each character.

The advantage to a monospaced font when displaying code is a string of 10 characters will always take up the same amount of space, so it’s easier to visualize variable lengths. Punctuation symbols can also be quite narrow and harder to see in non monospace fonts.fontMonoSpace

Ligatured fonts

Ligatured fonts are the fonts which have characters that connect to each other. If you are going to use a ligatured font for coding make sure it is designed for coding. e.g. Fira Code, Monoid, or Hasklig. unless they were designed for displaying code. Scott Hanselman wrote an interesting blog post discussing ligatured fonts. 

Ligatured fonts have a very different look when programming, some people absolutely love it, but it might cause confusion to an audience that is not familiar with this type of font.  The characters on the left are with ligatures, the characters on the right are without ligatures.

If you like ligature fonts, but your audience is confused by them, most code editors give you the ability to turn off ligatures for ligature supported fonts.

DisableLIgatures

There are other decisions to make with regards to font for code demonstrations including font color and size, but picking a suitable font is a great place to start!