On Tuesday, March 24, 2015 at 7:22:32 PM UTC-4, Adrian wrote:
> On Tuesday, March 24, 2015 at 2:16:30 PM UTC-4, Adrian wrote:
> > I'd like to jump between the console and the editor without having the console scroll up.
> > 
> > Is there a way that this can be done?  I see that there are terminal codes that save and restore the screen and this seems to be what vim uses to restore the console when you shell or Ctrl-Z out, so there must be a way to restore it without causing the shell to be invoked resulting in the terminal being scrolled up. Then a user can hit any key to restore the vim display.
> > 
> > If this isn't a default feature, could this be done in scripting?
> > 
> > Thanks,
> > 
> > 
> > A
> 
> Ok, so I've figured out how I can do this with Gary Johnson's help in how to run the tput commands from vim.  Here is my solution:
> 
> 1. Have the following script in vim memory:
> 
>     function! ShowTerm()
>         call system(">/dev/tty tput rmcup")
>         call input("")
>         call system(">/dev/tty tput smcup")
>         redraw!
>     endfunction
> 
> 2. Map the script to some command key sequence like this:
> 
>     map [= :call ShowTerm()<CR>
> 
> I used the sequence "[=", but you can use whatever you want.
> 
> Now type the key sequence and BOOM! you get the other screen.  Press Enter and BOOM! back to the vim screen.  The Enter doesn't add a line feed to the terminal screen either, so no marching lines.
> 
> Nice! :)
> 
> Thanks all!
> 
> 
> A
In order not to be dependent on `tput` being available, I've found that the following that @MarkPlotnick (from unix.stackexchange.com) inferred works just as well.  Just replace the function `ShowTerm()` above with:
    function! ShowTerm()
        silent !read -sN 1
        redraw!
    endfunction
This depends on `bash` being used as the shell (or others that have a similar read call).
-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment