How to Become a Command Prompt Ninja With Function Key Shortcuts

Sandeep Agarwal

Previously we have covered 10 brilliant Command Prompt tricks and 15 awesome Windows Run commands. Knowing these commands and tricks definitely gives you an edge over others when you require working on Windows Command Prompt (a lot of those Run commands actually work in Command Prompt too) . Besides, if you can master the relevant keyboard shortcuts, you will find that you can execute commands almost effortlessly.

Today we will talk about the actions associated to Function keys (F1 through F9) while you are on the ‘cmd’ window. They are mainly used to deal with the command history. Let us have some fun!

F1 to Repeat Previous Commands

Whenever you press this key it repeats the previous command’s characters one by one. Say for example, your previous command was title Guiding Tech. Pressing F1 once will write t, twice will write ti, thrice will write tit and so on.

F2 to Copy Part of Previous Command

The F2 key can be used to copy a part of the previous command, from the beginning to a specific letter. For instance, the last command that I executed was title Guiding Tech and then I hit F2 followed by the letter g. As a result title Guidin got populate on the current cursor position.

Image-F2

Note: The letter that you key in is interpreted in a case sensitive manner. And if the occurrence of that letter is more than once, the first occurrence will take effect.

F3 Can Be Used Like Up Arrow Key

It is equivalent to pressing the up arrow key (only once). Simply pulls out the last command that has been executed.

Image-F3

F4 to Remove Certain Letters

Have you ever wanted to remove a set of contiguous letters from some command that you have already typed? Just press F4 and you will see how easy that becomes. Based on the position of the cursor, you can key in a letter up till where you want to delete.

Image-F4

In the image, my cursor was on t, I keyed in g and the result I got was tig Tech. ­I find it really useful when I have to perform tasks that require me to modify a command each time I execute it, especially, when the command is a long one.

F5 to Get the Last Command

While F3 pulls out the last command (viz. only the last command no matter how many times you press that key) F5 can be used to scroll the previous commands one by one. So, it is equivalent to pressing the up arrow key (each time you press it, you will be scrolled one command down the cycle). However, it will go on till you reach the first command and will not circulate back to the last command.

Image-F5-F8

F6 to Put ^Z

It places the ^Z sequence on board. Now, I am not really sure about what command-action is mapped to that. Tell us, if you are aware.

Image-F6

F7 to View a List of Command History

As soon as you hit F7 a list of your command history will appear. Then you can scan the items using the up/down arrow keys. When you hit Enter on the highlighted one that command will be executed. Remember, it will not just be pulled out, but executed.

Image-F7

F8 to View an Infinite List of Your Command History

Similar to F5 with a difference that it cycles and circulates the history infinitely, meaning, the last command would reappear after the first.

F9 to Get a Specific Command

This is used to populate the current line with a specific command number from the history. Starting from the first (command number 0) you can hit F9 followed by a number to show that command. For referring the command number you may use F7. And unlike F7 it will not execute the command till you press Enter.

Image-F9

It is obviously better than hitting the up arrow key or F5/F8 blindly looking for a command from the history. Note that an invalid number will show the last executed command.

Conclusion

Some of these can be achieved by using the arrow keys alone. And there could be other key combinations for the rest as well. However, if you can memorize these key-command combinations and start practicing when you’re on cmd, you might find it much easier to use Function keys instead of arrows. Do tell us if you’ve got more Command Prompt tricks up your sleeve.

Also See
#cmd#function keys

Join the newsletter