899

I keep seeing the recording message at the bottom of my gVim 7.2 window.

What is it and how do I turn it off?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
  • 71
    To turn off vim recording for good, add `map q ` to your .vimrc file. – Joey Adams Aug 17 '10 at 16:26
  • 9
    I can't believe you want to turn recording off! I would show a really annoying popup 'Are you sure?' if one asks to turn it off (or probably would like to give options like the Windows 10 update gives). – 0xc0de Aug 12 '16 at 09:04
  • 3
    Related: *[How do I exit the Vim editor?](https://stackoverflow.com/questions/11828270/how-do-i-exit-the-vim-editor)* – Peter Mortensen May 18 '20 at 01:40

6 Answers6

1268

You start recording by q<letter> and you can end it by typing q again.

Recording is a really useful feature of Vim.

It records everything you type. You can then replay it simply by typing @<letter>. Record search, movement, replacement...

One of the best feature of Vim IMHO.

s4y
  • 50,525
  • 12
  • 70
  • 98
yogsototh
  • 14,371
  • 1
  • 22
  • 21
  • 126
    As seen other places, it's q followed by a register. A really cool (and possibly non-intuitive) part of this is that these are the *same* registers used by things like delete, yank, and put. This means that you can yank text from the editor into a register, then execute it as a command. – Cascabel Oct 06 '09 at 20:13
  • 79
    One more thing to note is you can hit any number before the @ to replay the recording that many times like (100@) will play your actions 100 times – Tolga E Aug 17 '13 at 03:07
  • 7
    You could add it afterward, by editing the register with put/yank. But I don't know why you'd want to turn recording on or off as part of a macro. ('q' doesn't affect anything when typed in insert mode.) – anisoptera Dec 04 '14 at 09:43
  • 1
    Hey @Jefromi, do you know what registers are used by delete, yank and put? Or are they custom ones only accessible by vim – Jay Jul 29 '15 at 14:15
  • 3
    @Wade `"` - it's called the default register. – Cascabel Jul 29 '15 at 14:52
  • @N0thing What, you mean what if you wanted a recording which let you create another recording? –  Sep 23 '15 at 13:24
  • 28
    `and how to turn off` was also the question – n611x007 Oct 04 '15 at 07:11
  • 13
    Cool but wrong key, i can't recall how many billion time i want to :q to quit and it go to recording. It happen because i type q too fast and then try to redo :q and it go to recording. – 林果皞 Apr 12 '16 at 07:25
  • 2
    A bit of dissent here: vim is OK, but the first thing I do in every environment is to `set compatible`. You know, if I wanted all those 'smart' features, I'd use emacs; I use vi for its combination of simplicity, efficiency and portability. – j4nd3r53n Oct 08 '18 at 14:47
  • 1
    That q does not help. No reaction. Looking at vim I am proud for all programmers of the world that greatly moved the requirements and convenience of technology during last 40 years. Even Microsoft starts to look well in comparison. – Gangnus Jun 28 '19 at 08:22
  • 1
    What if you need to use the letter q in your recording? How would you use it without ending the recording? – jhaubrich.com Aug 30 '21 at 16:23
  • A few people here see this as a very powerful tool, so now I'm curious: what so good about it? Can you give a specific situation where recording is useful? I'm wondering what I am missing! – physincubus Aug 11 '22 at 00:32
  • 1
    @physincubus One sort of simple case is when you have some key word you want to replace in the buffer, but not every instance: it could be that only every third instance of the keyword is one you want to replace. So that would involve a pattern of something like '3nce' repeated many many times. If you record it in register 'q', you could run 1000@q to run the sequence 1000 times and if you set nowrapscan, it can save a lot of repetition – Rondo Apr 20 '23 at 05:16
113

Type :h recording to learn more.

                           *q* *recording*
q{0-9a-zA-Z"}           Record typed characters into register {0-9a-zA-Z"}
                        (uppercase to append).  The 'q' command is disabled
                        while executing a register, and it doesn't work inside
                        a mapping.  {Vi: no recording}

q                       Stops recording.  (Implementation note: The 'q' that
                        stops recording is not stored in the register, unless
                        it was the result of a mapping)  {Vi: no recording}


                                                        *@*
@{0-9a-z".=*}           Execute the contents of register {0-9a-z".=*} [count]
                        times.  Note that register '%' (name of the current
                        file) and '#' (name of the alternate file) cannot be
                        used.  For "@=" you are prompted to enter an
                        expression.  The result of the expression is then
                        executed.  See also |@:|.  {Vi: only named registers}
ephemient
  • 198,619
  • 38
  • 280
  • 391
59

Typing q starts macro recording, and the recording stops when the user hits q again.

As Joey Adams mentioned, to disable recording, add the following line to .vimrc in your home directory:

map q <Nop>
mitchus
  • 4,677
  • 3
  • 35
  • 70
  • 18
    only answer about "how to turn off" part of the question. Well, it makes recording inaccessible, effectively turning it off - at least noone expects vi to have a separate thread for this code, I guess, including me. – n611x007 Oct 04 '15 at 07:16
44

It sounds like you have macro recording turned on. To shut it off, press q.

Refer to ":help recording" for further information.

Related links:

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
30

As others have said, it's macro recording, and you turn it off with q. Here's a nice article about how-to and why it's useful.

JeffH
  • 10,254
  • 2
  • 27
  • 48
27

It means you're in "record macro" mode. This mode is entered by typing q followed by a register name, and can be exited by typing q again.

John Millikin
  • 197,344
  • 39
  • 212
  • 226
  • It's actually entered by typing `q` followed by any register name, which is 0-9, a-z, A-Z, and ". – ephemient Oct 06 '09 at 20:08
  • 4
    Actually, it's q{0-9a-zA-Z"} - you can record a macro into any register (named by digit, letter, "). In case you actually want to use it... you execute the contents of a register with @. See `:help q` and `:help @` if you're interested in using it. – Cascabel Oct 06 '09 at 20:08