reynoldsnlp
reynoldsnlp

Reputation: 1210

vi/vim repeat :bw with one keystroke?

I am manually processing a very large number of files and so I use vim *.txt to open a batch of files and then :bw to close a file and move to the next one in the buffer. This works, but I would like to have a way to repeat :bw with one keystroke, the same way that you can use . to repeat the last command. (If I use ., it repeats the command that I had done before :bw, which was dd.)

Upvotes: 1

Views: 401

Answers (2)

romainl
romainl

Reputation: 196576

If you don't use any ex command in the meantime you can use @: to repeat the last ex command.

Anyway, I recommend a quick mapping like:

nnoremap <key> :bwipeout<CR>

Upvotes: 3

reynoldsnlp
reynoldsnlp

Reputation: 1210

It is possible to get this down to two keystrokes by recording a macro: qa:bw<enter>q. The macro is then called with @a (or @@ if it was the last macro used). Especially if you are passing over many consecutive files, @@ is much faster/easier to type than :bw.

Upvotes: 0

Related Questions