HUD is disabled with the cl_drawhud 0 command and enabled again with cl_drawhud 1. Additionally r_drawviewmodel 0 and r_drawviewmodel 1 can be used to toggle the viewmodel. Instead of pasting the commands into the console every time I want to capture a screenshot I'd prefer a hotkey to toggle (H would be sensible) which can be achieved by using alias, I believe.

  • Then this might be useful. If not a duplicate as well.
    – Joachim
    Commented Feb 28, 2019 at 19:27

2 Answers 2


I am not sure, if all Source engine games do it this way, but in Team Fortress 2 I use the autoexec.cfg file together with a few additional files. >Reference to a relevant Portal 2 question

Of course, you can also use the syntax described below directly in the console as well - it just won't be persistent that way.

In the games config directory (e.g. Team Fortress 2/tf/cfg) you can find (or create if it isn't there) a file called autoexec.cfg. You should not change the existing config.cfg, but you can have a look into that file for further reference.

In this autoexec.cfg file we can add commands that will be automatically called on launch of the game. You should be able to add a line for your keybind in here. The syntax may look like the following:

bind "h" "incrementvar r_drawviewmodel 0 1 1"
bind "j" "incrementvar cl_drawhud 0 1 1"

This will toggle the r_drawviewmodel command each time you press the "h"-Button. The incrementvar keyword will count upwards from 0 until it reaches 1 by increments of 1 - that's how that works. It works the same on on the "j"-key with cl_drawhud. If you want to do both at the same time, you can use a semicolon to bind multiple command to one key:

bind "h" "incrementvar r_drawviewmodel 0 1 1; incrementvar cl_drawhud 0 1 1"

The last line is sometimes needed, sometimes not - it can be frickly and different from game to game in my experience.

In certain games sv_cheats might need to be set to 1 for this to work (I just encountered this problem in CS:GO).

You may also want to make sure to save the file in UTF-8 encoding, if it is not working. When using the Windows Notepad, there is a dropdown menu in the save file interface that reads ANSI by default.

  • I know that host_writeconfig is mandatory in Counter-Strike: Global Offensive autoexec.
    – user598527
    Commented Feb 28, 2019 at 20:38
  • I recommend editing the command in your answer to bind "h" "incrementvar cl_drawhud 0 1 1", but it's good to mention the viewmodel command as well.
    – user598527
    Commented Feb 28, 2019 at 20:41
  • I edited my answer to include both commands that were mentioned in the question.
    – Faxter
    Commented Feb 28, 2019 at 20:58
  • Also, you might be able to put both commands onto one button by using a semicolon, but I have not tested that yet.
    – Faxter
    Commented Feb 28, 2019 at 21:02
  • I just confirmed that you can use both commands on one key using a semicolon to separate them - edited that into my answer.
    – Faxter
    Commented Feb 28, 2019 at 21:27

You can use the following commands in your Source game (tested in Half-Life 2: Episode 2). Paste and enter one line at a time:

alias noHUD "HUD_toggle1"
alias HUD_toggle1 "cl_drawhud 0; r_drawviewmodel 0; alias noHUD HUD_toggle2"
alias HUD_toggle2 "cl_drawhud 1; r_drawviewmodel 1; alias noHUD HUD_toggle1"
bind "h" noHUD

The names of the functions eventually don't really matter.

  • I'm using the commands in HL2: Episode 2 as well and haven't got the toggle to work yet. I paste everything at once to the console, right? Your formatting implies that the commands must be used individually. I will of course save the script in autoexec once it functions.
    – user598527
    Commented Feb 28, 2019 at 20:30
  • 1
    I think the last line should be "bind "h" noHUD", shouldn't it?
    – Faxter
    Commented Feb 28, 2019 at 21:00
  • @Faxter you are very right. And the lines should be fed to the console one at the time. Edited.
    – Joachim
    Commented Feb 28, 2019 at 21:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .