tags:

views:

42

answers:

2

In VIM, I want to execute a command (like :!mkdir src/main/scala/xxx) Then, I want to also make a subdirectory of the just created directory. Can I have VIM retype the last used command and then I append the sub directory name to it (So I can have :!mkdir scr/main/scala/xxx/yyy without retyping the whole stuff).

+4  A: 

Can't you just hit : then the up arrow to go through your command history?

GWW
Or `:!` then up arrow to go through the commands that start with `!`
Dave Kirby
+2  A: 
:!mkdir test
:!!/test2

will do what you want, see :h :!. Citation from there:

Any '!' in {cmd} is replaced with the previous external command (see also 'cpoptions').

// Why don't you use -p switch to mkdir? mkdir -p test/test2/test3/... will create directory with all its parents if they do not exist.

ZyX
Thank so much for the awesome tip on `!` and `-p` switch.
Phương Nguyễn