On 11-Jul-09 17:36, mobi phil wrote:
> On Sat, Jul 11, 2009 at 4:55 PM, Ingo Karkat <[email protected]
> <mailto:[email protected]>> wrote:
> On 11-Jul-09 16:52, Ben Fritz wrote:
> > You're worried about destroying window layout if you just redirect to
> > a new Window.
> >
> > So why redirect to a new Window? Redirect to a new TAB PAGE instead,
> > then close the tab when done. Extremely simple, no additional
> > functionality needed, and your Window layout remains untouched.
>
> ... or save the current window layout with winrestcmd() and restore
> it afterwards.
>
> -- ingo
>
> I am using vim for speed... I use this kind of lists very often. And I
> do not have a TAB-bed window. I tried to describe a use case, but it is
> difficult to convince by describing it... Completion would be one way,
> however that is also limited, as you cannot search in the completion lists.
>
> I tried to describe this with the MRU files list. I use such lists
> intensively, and I am sure most of you do so. I have other lists like
> lists of links, lists of files in a projects. And the usage pattern is
> to find quickly a file in this list, and either insert it at the cursors
> position, or do a command on it. Another usage is translation. If I
> could open a file with translation of words in a certain language, I
> could search fast in the list (and more than 50% of the cases I search
> nor for from the beginning nor at the end of the word, I search for the
> pattern in the word that would bring me the result the fastest). Once
> the word found, enter, the result would be inserted at cursor position.
>
>
> Well... I will have a look at the code and investigate myself.. I hoped
> smbdy would share my idea..
Your use case sounds like "scratch buffers", which are temporarily opened by a
mapping, you navigate in it, then often select an entry by hitting <Return>,
which then closes the scratch buffer and returns to the original window. Many
plugins (project.vim, taglist.vim) use this approach to emulate an IDE's
sidebar, task list, etc. Vim's built-in command-line window (q:) and quickfix
window (:copen) are like that, too.
To implement such a thing in Vimscript, save the current window layout via
let save_layout = winrestcmd()
then :split open the scratch buffer. Inside that special buffer, you often set
up mappings to acknowledge and close that buffer, e.g.
nmap <CR> :let selected_line = getline('.')<Bar>close<Bar>silent! execute
save_layout<CR>
but you could also setup an :autocmd on closing / leaving the scratch buffer to
restore the layout. With the autocmd, you are able to close the scratch buffer
with any built-in Vim command like CTRL-W_c.
Unless I misunderstood your use case, winrestcmd() (and maybe also
winsaveview()) is all you need to implement temporary windows that restore the
window layout.
-- regards, ingo
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---