Questions tagged [vim-macros]

Recording a macro is a great way to perform a one-time task, or to get things done quickly when you don't want to mess with Vim script or mappings, or if you do not yet know how to do it more elegantly.

In Vim, the word macro may refer to:

  • A sequence of commands recorded to a register (this tip).
  • A mapping to expand a sequence of typed keys to a longer sequence (see tutorial).
  • A script written in the Vim script language (stored in a file with extension .vim – see :help script).

Recording a macro

Each register is identified by a letter a to z.

To enter a macro, type:

  • q<letter><commands>q

To execute the macro <number> times (once by default), type:

  • <number>@<letter>

So, the complete process looks like:

  • qq: start recording to register q
  • ... : your complex series of commands
  • q : stop recording
  • @q: execute your macro
  • @@: execute your macro again

References

34 questions
0
votes
4 answers

Vim : time increment in a schedule

I'm new to Vim and I'm trying to see what I can / can't do with it. I would like to increment a list of times like this : 09:00 Breakfast 09:30 RSS 09:50 Stretch 10:00 Main proj 13:00 food 14:00 Main proj... Lets say I woke up too late, and I'd…
DaftWooly
  • 348
  • 3
  • 7
0
votes
2 answers

VI(M), search in two files and scroll to result in two files automatically

I have been doing these operation and require to do it often. step 1. Search for a string (SHFT + *) step 2. Switch to previous view port (CTRL + w + h) step 3. Find the string ( n ) step 4. Return to the other view port (CTRL + w + l) …
AjayKumarBasuthkar
  • 2,885
  • 2
  • 23
  • 27
0
votes
1 answer

How would you make this into a VIM macro?

So one of the common tasks that I do as a programmer is debugging a live system. And one of the ways that I debug a live system is to capture a verbose log from the console. Typically the log file has around 20 extra lines for every one line I am…
Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
-1
votes
1 answer

How do I store a golang template macro in vim

I want to store the following code permanently in the .vimrc file. Can anyone provide me the code to do so? package main import "fmt" func main() { fmt.Println("Hello World") }
1 2
3