When I take notes for CS classes, I find myself constantly changing the font choice and weight to differentiate lines of code from regular notes. For example:

formatting example

To improve productivity, I would like to be able to highlight a chunk of text and apply a keyboard shortcut to change the font of just that chunk of text.

I have found an imperfect workaround. By changing the default font for header 1 to my desired formatting, I can select Ctrl+Alt+1 to change the selected line to my desired format. However, this method doesn't allow me to change individual words or phrases on a line without changing the whole line.

Is there some way to create a keyboard shortcut to change the highlighted text to a custom font (in my case, courier new, bold, size 11)?