Vim: Is there a way to repeat a CLI command?

Created on 29 May 2017  路  8Comments  路  Source: VSCodeVim/Vim

For example, can we repeat a :s/foo/bar/g without retyping it?
I've looked around but haven't been able to find anything about this (maybe I've missed it)

help wanted kinfeature

Most helpful comment

It actually is a core vim feature, namely typing @: in vim (in normal mode) repeats the last command (to be more precise, the last command is saved in the special : register, so you can even see it by typing :register or by pasting it into the text via ":p).

All 8 comments

Gotcha - is there a command for this in the meantime (something we could bind to a key ourselves)? If not I may try to add it and PR

Unluckily, it's not really possible right now. VSCode doesn't allow us to modify the box that pops up for Ex commands.

It would be possible if we decided to move Ex-commands to the bottom status bar, but that doesn't seem worth it to me right now.

I mean like, what if we just made some keybind that runs the last command without any sort of interface popup?

So I type :s/foo/bar/g
Press enter to do the replace
go to some other line
press some key combination to rerun the same command again on that line

Oh, hmm. That's definitely possible. That would not be a core vim feature though.

It actually is a core vim feature, namely typing @: in vim (in normal mode) repeats the last command (to be more precise, the last command is saved in the special : register, so you can even see it by typing :register or by pasting it into the text via ":p).

+1

This should come for "free" with #2193 and #3605
Edit: actually, not quite. Vim treats @: a bit differently than other macros, but it shouldn't be too bad.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerardmrk picture gerardmrk  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

AndersenJ picture AndersenJ  路  3Comments

spinningarrow picture spinningarrow  路  3Comments

ghost picture ghost  路  3Comments