a cross between CTRL-^ and CTRL-O?

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

a cross between CTRL-^ and CTRL-O?

Maciej Kalisiak-3
I have a "stack-based" editing workflow.  For example,
  - I may be editing foo.c
  - decide I need to check something in bar.c (":e bar.c")
  - coincidentally, found a bug in bar.c, made a small change
  - turns out what I seek is elsewhere (":e baz.c")
  - I get a phonecall and need to jot down notes (":e blah.txt")
  - now I want to "go back" to what I was doing (-> baz.c)
  - I found what I needed; "go back" further (-> bar.c)
  - I should probably check in this bugfix; ok, now "go back" (-> foo.c)
  - and I am back to my main editing task

My question is, what is the best way to achieve this buffer maneuvering in
Vim?  In Emacs it was easy to achieve, since anytime I wanted to go back, I
would simply "bury" the current buffer, which would basically put it at the
bottom of the buffer list, which is stack-like in Emacs.  From what I
understand, the buffer list in Vim is more static, in the sense that once a
buffer is opened, it is assigned a static number/position in the list for
the duration of its lifespan.  I can almost achieve what I seek with either
CTRL-O or CTRL-^, but each is lacking in some regard.  CTRL-O/:jumps are
nice, but the downside is that I might have to do a number of CTRL-O
keypresses to get to the previous *file*; I'd like to achieve the same with
a *single* keystroke.  CTRL-^ does this, but it's not stack based, so I
cannot go back two or more times in a row.  I'm aware that it takes a
[count], but this is not helpful; consider the workflow:
  - go back one file(CTRL-^)
  - inspect for any outstanding work; no? save & go back one more file (???)
  - repeat last step arbitrary number of times...

It's almost like what I seek is a mix of CTRL-^ and CTRL-O...  suggestions?

--
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

A.J.Mechelynck
----- Original Message -----
From: "M.K." <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, August 10, 2005 9:49 PM
Subject: a cross between CTRL-^ and CTRL-O?


>I have a "stack-based" editing workflow.  For example,
>  - I may be editing foo.c
>  - decide I need to check something in bar.c (":e bar.c")
>  - coincidentally, found a bug in bar.c, made a small change
>  - turns out what I seek is elsewhere (":e baz.c")
>  - I get a phonecall and need to jot down notes (":e blah.txt")
>  - now I want to "go back" to what I was doing (-> baz.c)
>  - I found what I needed; "go back" further (-> bar.c)
>  - I should probably check in this bugfix; ok, now "go back" (-> foo.c)
>  - and I am back to my main editing task
>
> My question is, what is the best way to achieve this buffer maneuvering in
> Vim?  In Emacs it was easy to achieve, since anytime I wanted to go back,
> I
> would simply "bury" the current buffer, which would basically put it at
> the
> bottom of the buffer list, which is stack-like in Emacs.  From what I
> understand, the buffer list in Vim is more static, in the sense that once
> a
> buffer is opened, it is assigned a static number/position in the list for
> the duration of its lifespan.  I can almost achieve what I seek with
> either
> CTRL-O or CTRL-^, but each is lacking in some regard.  CTRL-O/:jumps are
> nice, but the downside is that I might have to do a number of CTRL-O
> keypresses to get to the previous *file*; I'd like to achieve the same
> with
> a *single* keystroke.  CTRL-^ does this, but it's not stack based, so I
> cannot go back two or more times in a row.  I'm aware that it takes a
> [count], but this is not helpful; consider the workflow:
>  - go back one file(CTRL-^)
>  - inspect for any outstanding work; no? save & go back one more file
> (???)
>  - repeat last step arbitrary number of times...
>
> It's almost like what I seek is a mix of CTRL-^ and CTRL-O...
> suggestions?
>
> --
> [hidden email]
>
>
>

    :jumps

will tell you what count to prefix to the Ctrl-O command (or Ctrl-I if
jumping forward)

On my system it shows the line in blue (same file) or the file path&name in
black (another file).

HTH,
Tony


Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Yegappan Lakshmanan
In reply to this post by Maciej Kalisiak-3
Hello,

On 8/10/05, M.K. <[hidden email]> wrote:

>
> My question is, what is the best way to achieve this buffer maneuvering in
> Vim?  In Emacs it was easy to achieve, since anytime I wanted to go back, I
> would simply "bury" the current buffer, which would basically put it at the
> bottom of the buffer list, which is stack-like in Emacs.  From what I
> understand, the buffer list in Vim is more static, in the sense that once a
> buffer is opened, it is assigned a static number/position in the list for
> the duration of its lifespan.  I can almost achieve what I seek with either
> CTRL-O or CTRL-^, but each is lacking in some regard.  CTRL-O/:jumps are
> nice, but the downside is that I might have to do a number of CTRL-O
> keypresses to get to the previous *file*; I'd like to achieve the same with
> a *single* keystroke.  CTRL-^ does this, but it's not stack based, so I
> cannot go back two or more times in a row.  I'm aware that it takes a
> [count], but this is not helpful; consider the workflow:
>   - go back one file(CTRL-^)
>   - inspect for any outstanding work; no? save & go back one more file (???)
>   - repeat last step arbitrary number of times...
>
> It's almost like what I seek is a mix of CTRL-^ and CTRL-O...  suggestions?
>

You can try the MRU (Most Recently Used) plugin. The MRU plugins maintains
the list of recently edited files (in the LIFO order)

http://vim.sourceforge.net/scripts/script.php?script_id=521

This plugin also works across different Vim instances and sessions.

- Yegappan
Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Aaron Griffin
In reply to this post by Maciej Kalisiak-3
I'm a big fan of the bufferlist.vim plugin, which is rather new:
http://www.vim.org/scripts/script.php?script_id=1325

Make sure to read the plugin file first, as it has some config info in it
Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Maciej Kalisiak-3
In reply to this post by A.J.Mechelynck
--On Wednesday, August 10, 2005 16:06:31 -0400 Tony Mechelynck
<[hidden email]> wrote:

>     :jumps
>
> will tell you what count to prefix to the Ctrl-O command (or Ctrl-I if
> jumping forward)
>
> On my system it shows the line in blue (same file) or the file path&name
> in black (another file).
>
> HTH,
> Tony

Yeah, that's what I've been using as a workaround for the time being, but
hopefully I can find something quicker, single-keypress. If I find nothing
else I'll try to package the multiple steps (:jumps, inspect list,
<n>CTRL-O) into a script that can be bound to a key... but hopefully
something like this already exists.

--
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Hari Krishna Dara
In reply to this post by Maciej Kalisiak-3

On Wed, 10 Aug 2005 at 4:44pm, M.K. wrote:

> --On Wednesday, August 10, 2005 16:06:31 -0400 Tony Mechelynck
> <[hidden email]> wrote:
>
> >     :jumps
> >
> > will tell you what count to prefix to the Ctrl-O command (or Ctrl-I if
> > jumping forward)
> >
> > On my system it shows the line in blue (same file) or the file path&name
> > in black (another file).
> >
> > HTH,
> > Tony
>
> Yeah, that's what I've been using as a workaround for the time being, but
> hopefully I can find something quicker, single-keypress. If I find nothing
> else I'll try to package the multiple steps (:jumps, inspect list,
> <n>CTRL-O) into a script that can be bound to a key... but hopefully
> something like this already exists.
>
>

Are you not using any buffer explorer to switch between buffers? Some
buffer explorers (SelectBuf, bufexplorer) support an MRU order of the
buffers so it is easy to open the plugin window and see for yourself
what order you had the buffers visited. An option to freeze the MRU
order will probably be useful (and I might add that to SelectBuf
sometime).

If you want to use Vim primitives, how about using the global marks
(the upper case marks, called file marks)? Though this means you have to
remember to add a mark before you switch to another buffer, it will make
it easier to come back to them. You might also be able to create a
really simple script that on demand can assign the next available upper
case mark (keeping track of the next available mark locally, kind of
like pushing on to the stack), and later on demand switch to the
position of the top most mark and make it available (kind of popping
from stack). Though this means you will not be able to use the upper
case marks for regular purposes, I have never really needed to use them
anyway.

--
HTH,
Hari


               
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs 
 
Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Alan Schmitt
In reply to this post by Aaron Griffin
On 10 août 05, at 22:41, Aaron Griffin wrote:

> I'm a big fan of the bufferlist.vim plugin, which is rather new:
> http://www.vim.org/scripts/script.php?script_id=1325
>
> Make sure to read the plugin file first, as it has some config info  
> in it

This is a really cool plugin, which nicely completes the MRU plugin  
(which I also recommend).

Alan

--
The hacker: someone who figured this out and made something cool happen.
.O.
..O
OOO



PGP.sig (193 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: a cross between CTRL-^ and CTRL-O?

Arun Easi
In reply to this post by Maciej Kalisiak-3
May be an overkill, but you could try ":mksession <file>" at the start and
":source <file>" to restore to the previous editing seesion. Use some
keymapping to make this switch easier.

-Arun

On Wed, 10 Aug 2005, M.K. wrote:

> I have a "stack-based" editing workflow.  For example,
>   - I may be editing foo.c
>   - decide I need to check something in bar.c (":e bar.c")
>   - coincidentally, found a bug in bar.c, made a small change
>   - turns out what I seek is elsewhere (":e baz.c")
>   - I get a phonecall and need to jot down notes (":e blah.txt")
>   - now I want to "go back" to what I was doing (-> baz.c)
>   - I found what I needed; "go back" further (-> bar.c)
>   - I should probably check in this bugfix; ok, now "go back" (-> foo.c)
>   - and I am back to my main editing task
>
> My question is, what is the best way to achieve this buffer maneuvering in
> Vim?  In Emacs it was easy to achieve, since anytime I wanted to go back, I
> would simply "bury" the current buffer, which would basically put it at the
> bottom of the buffer list, which is stack-like in Emacs.  From what I
> understand, the buffer list in Vim is more static, in the sense that once a
> buffer is opened, it is assigned a static number/position in the list for
> the duration of its lifespan.  I can almost achieve what I seek with either
> CTRL-O or CTRL-^, but each is lacking in some regard.  CTRL-O/:jumps are
> nice, but the downside is that I might have to do a number of CTRL-O
> keypresses to get to the previous *file*; I'd like to achieve the same with
> a *single* keystroke.  CTRL-^ does this, but it's not stack based, so I
> cannot go back two or more times in a row.  I'm aware that it takes a
> [count], but this is not helpful; consider the workflow:
>   - go back one file(CTRL-^)
>   - inspect for any outstanding work; no? save & go back one more file (???)
>   - repeat last step arbitrary number of times...
>
> It's almost like what I seek is a mix of CTRL-^ and CTRL-O...  suggestions?
>
> --
> [hidden email]
>