Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim "show my last command" command?

Tags:

vim

vi

Is there a command which shows what was the last command in normal mode?

Suppose I accidently hit random key and got some unexpected result. Sure I can undo it, but could I reveal what key was pressed and how it was interpreted?

like image 589
dvs Avatar asked Jan 19 '12 14:01

dvs


People also ask

How do I find previous commands in vim?

Press Ctrl+F in command mode to open the command history window. Then, you can use / , ? , and other search commands. Press Enter to execute a command from the history.

Does vim have history?

Vim text editor is capable of recording the history of all the commands that we enter on the command line prompt. There are two ways of recalling the command history: dialling up the command line window or scrolling through the past command lines using the cursor keys.

How do you go last in vi?

If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.

What shortcut you use to find a previously ran command?

To get previous command containing string, hit [CTRL]+[r] followed by search string: (reverse-i-search): To get previous command, hit [CTRL]+[p]. You can also use up arrow key.


1 Answers

Hit the colon (:) and then use the up arrow to start going back through previous commands. You can use the up/down arrows too to move around the list.

like image 148
user3620332 Avatar answered Oct 08 '22 14:10

user3620332