Comment and uncomment hotkeys in wordpress development

In this post we will show you how you can easily comment and uncomment code.


Code commenting for wordpress development

What is a coding comment

All programs code should also have comments so that it is easy for a human to read the purpose of the code.

For example (PHP)

//this function will display ‘hello world’

function display_hello_world(){

echo ‘hello world’;


That, in theory is the purpose of code commenting. If you are looking for the answer to the question ‘how to use hotkeys for commenting in wordpress’, it is likely that you already know the purpose of commenting in coding. It is also very likely that you, like all coders, find the purpose of the commenting is to comment out sections for testing or comment it out, to ‘use it later’ :).

I found it very hard to find the answer to using hotkeys to comment coding in functions file of wordpress (or any other php file), directly though the code editor, so I have given this post for those of you who don’t want to spend too much time getting results related to hotkeys for wordpress comments – something compleytelcompletely different!

The following section will define how to use hot keys that allow you to comment a line or lines of coding through the wordpress theme editor or plugin editor.


Line Comments – use with php for commenting and uncommenting on WordPress

Line comments are your standard ctrl + / on Windows/Linux or cmnd + / on OSX. In languages where there are more than one type of comment, like JavaScript and most preprocessors, line comments only comment out a single line. In languages where there is only one type of comment, like vanilla CSS and HTML, line comments will behave similarly to block comments (/* */ and <!-- -->).

Unless there is no true line comment (vanilla HTML and CSS), the line comment shortcut will comment out the entire line your cursor is in (even if you haven’t selected the whole line).


Block Comments – use with CSS or Javascript for commenting and uncommenting on WordPress

To make a block comment:

  • On a PC: Ctrl + Shift + /
  • On a Mac: Command + Opt + /

The biggest difference with block comments is that they are very selection-sensitive. If nothing is selected, the block comment shortcut typically injects an empty block comment at the cursor position. If you have a selection, it will only wrap the selection.



I have now described how to use hotkeys to comment and uncomment through the wordpress editor. Happy coding and don’t forget to remove your commented out code… you probably won’t use it in the future 🙂

enqueue scripts
enqueue scripts
enqueue scripts

…We do more, so you can do less 🙂

Leave a message and we will be straight back to you!

Pin It on Pinterest

Share This