4 Questions (about macro, repeat command, buffer menu, session)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

4 Questions (about macro, repeat command, buffer menu, session)

Chandrasekaran V.
Dear vimmers,

1. Is it possible to hand-edit a macro that was recorded using 'q' ? Is the
macro key sequence
    stored anywhere like in .viminfo file?

2. The '.' repeats the last command. Is it possible to repeat nth command
from the last command ?
    Since vim maintains several previous commands (for undo operation), this
should be possible.
    Is this supported by vim ? Or is it just my "whim"?

3. If I open a file from the "Buffer" pull-down menu, it would exit the
current buffer and open
    the file in the current buffer space. Is it possible to make vim split
open the new window and
    open the newly selected file in the other half? May be Ctrl-Select could
do it? Is it mappable?

4. Is it possible to store the current session of vim (all open, active
buffers, line numbers etc.,) into
    a state file and later resume the session in a new vim ? ie.,

thanks a lot,
chandra.


Reply | Threaded
Open this post in threaded view
|

Re: 4 Questions (about macro, repeat command, buffer menu, session)

Tim Chase-2
 > 1. Is it possible to hand-edit a macro that was recorded using
 > 'q' ? Is the macro key sequence stored anywhere like in
 > .viminfo file?

They are stored in the registers, just like any other copy/cut
operation you perform with a register.  Thus, you can paste the
contents of the named register into your file, and make the edit,
and then yank it back.  Depending on the complexity of your
macro, this may be a tad unwieldy as funny things can happen with
control-keys and alt+character bindings:  I've had trouble
occasionally getting the exact-same contents back into my
register.  If you just need to make a simple change, you can also
do something like

        :let @a=substitute(@a,'foo','bar','')

which will replace the word "foo" with the word "bar" in your
macro "a".

 > 2. The '.' repeats the last command. Is it possible to repeat
 > nth command from the last command ?  Since vim maintains
 > several previous commands (for undo operation), this should be
 > possible.  Is this supported by vim ? Or is it just my "whim"?

Not that I've found in all my vimming.  I'm not sure how the
internals of undo/redo work in vim, but I suspect they just track
deltas of what's changed, not how it changed.

 > 3. If I open a file from the "Buffer" pull-down menu, it would
 > exit the current buffer and open the file in the current buffer
 > space. Is it possible to make vim split open the new window and
 > open the newly selected file in the other half? May be
 > Ctrl-Select could do it? Is it mappable?

Sounds like you're looking for the ":sbuffer" command.
Alternatively, you can just use ":sp" to split the new window.
Works in shell sessions and without that infernal rodent ;-)

 > 4. Is it possible to store the current session of vim (all
 > open, active buffers, line numbers etc.,) into a state file and
 > later resume the session in a new vim ? ie.,

You may want either ":mkview" or ":mksession" depending on which
one does what you want.  You can learn more at

     :help mkview
     :help mksession

Hope this helps,

-tim






Reply | Threaded
Open this post in threaded view
|

Re: 4 Questions (about macro, repeat command, buffer menu, session)

A.J.Mechelynck
In reply to this post by Chandrasekaran V.
----- Original Message -----
From: "Chandrasekaran V." <[hidden email]>
To: <[hidden email]>
Sent: Thursday, August 25, 2005 8:46 PM
Subject: 4 Questions (about macro, repeat command, buffer menu, session)


> Dear vimmers,
>
> 1. Is it possible to hand-edit a macro that was recorded using 'q' ? Is
> the macro key sequence
>    stored anywhere like in .viminfo file?

Yes and yes. The key sequence is stored in a register (usually, register a
to z). To write the key sequence to your current Vim buffer, use "xp
(assuming you recorded it using qx). To get it back into the register,
highlight it in Visual mode (using v followed by cursor moves) then use "xy

Registers can be stored in the viminfo, see ":help 'viminfo'".

>
> 2. The '.' repeats the last command. Is it possible to repeat nth command
> from the last command ?
>    Since vim maintains several previous commands (for undo operation),
> this should be possible.
>    Is this supported by vim ? Or is it just my "whim"?

Normal-mode commands: I don't think so but I don't know everything.
Searches and Ex-commands: yes. You can use command-line history (enter a
partial command-line then use <Up> and <Down>) or the command-line window
(see ":help cmdline-window").

>
> 3. If I open a file from the "Buffer" pull-down menu, it would exit the
> current buffer and open
>    the file in the current buffer space. Is it possible to make vim split
> open the new window and
>    open the newly selected file in the other half? May be Ctrl-Select
> could do it? Is it mappable?

A workaround would be to use ":new" before using the buffer window. If you
know the file name you can use ":new foo.bar" or ":split foo.bar" instead of
":e foo.bar".
>
> 4. Is it possible to store the current session of vim (all open, active
> buffers, line numbers etc.,) into
>    a state file and later resume the session in a new vim ? ie.,

see ":help :mksession"

>
> thanks a lot,
> chandra.

My pleasure,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: 4 Questions (about macro, repeat command, buffer menu, session)

Charles E Campbell Jr
In reply to this post by Chandrasekaran V.
Quoting "Chandrasekaran V." <[hidden email]>:

> 1. Is it possible to hand-edit a macro that was recorded using 'q' ?
>    Is the macro key sequence stored anywhere like in .viminfo file?

:he q

Note that the command sequence is:   q[register] ... q
The commands are stored in the register you selected; type "[register]p
to see them (ie.  qa ... q   ; type  "ap ).  Edit the line as you wish,
then type (with the cursor on the line and using register a):

        $xV"ay

(the $x gets rid of the trailing ^M that shows up)

> 2. The '.' repeats the last command. Is it possible to repeat nth command
> from the last command ?

The "." command repeats the last change, not any arbitrary normal mode command.
For example, use the "j" key to move down some lines; a "." will not repeat
that move.

Not as far as I know.

> 3. If I open a file from the "Buffer" pull-down menu, it would exit the
> current buffer and open the file in the current buffer space.
> Is it possible to make vim split open the new window and
> open the newly selected file in the other half? May be Ctrl-Select could
> do it? Is it mappable?

Yes, its quite possible.  Look at where your runtime files are and consider
menu.vim.  In there is the Buffer list menu support.  In BMFilename() is
a line...

  exe name . ' :confirm b' . a:num . '<CR>'

This needs to be changed to something like (untested)

  exe name . ' :confirm wincmd s bufname(' . a:num . ')<CR>'

or

  exe name . ' :confirm wincmd v bufname(' . a:num . ')<CR>'



> 4. Is it possible to store the current session of vim (all open, active
> buffers, line numbers etc.,) into a state file and later resume the
> session in a new vim?

:he session

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: 4 Questions (about macro, repeat command, buffer menu, session)

Chandrasekaran V.
In reply to this post by Chandrasekaran V.
Thanks to everyone for the useful information.

-chandra.