Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:59:01+00:00 2026-06-13T00:59:01+00:00

When using vim in the terminal, it essentially blanks out the terminal’s window and

  • 0

When using vim in the terminal, it essentially blanks out the terminal’s window and gives you a new one to start coding in, yet when you exit vim the terminal’s previous output is still listed. How do you clear the terminal so that it only outputs your program’s output, but returns to its normal state once the process has ended? (In linux, fedora)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:59:02+00:00Added an answer on June 13, 2026 at 12:59 am

    At the low level, you send the terminal program a set of control characters that tell it what to do. This can be a bit too complex to to manage manually.

    So instead, you might want to look at a console library like ncurses, which can manage all this complexity for you.

    With respect specifically to the previous content magically appearing after the program exits, that’s actually an xterm feature which vim is taking advantage of and which most modern terminals support. It’s called “alternate screen” or simply “altscreen”. Essentially you tell the terminal program “Ok, now switch to a completely new screen, we’ll come back to the other one later”.

    The command to switch to the alternate screen is typically \E[?47h, while the command to switch back is \E[?47l For fun try this:

    echo -e "\033[?47h"
    

    and then to switch back:

    echo -e "\033[?47l"
    

    Or for a more more complete solution which relies a bit less on your shell to set things right (these are the sequences vim normally uses):

    echo -e "\0337\033[?47h" # Save cursor position & switch to alternate screen
    # do whatever
    
    #Clear alternate screen, switch back to primary, restore cursor
    echo -e "\033[2J\033[?47l\0338" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using terminal Vim 7.3 on Mac OS X Lion and have the following
I have just started using Vim in a terminal (PuTTY or MinTTY), after always
I'm using VIM with pythoncomplete. When I'm making a completion, the current window is
I have installed CakePHP 2.0 framwork using steps below: 1. Start the terminal 2.
I have been using R in the terminal window for Ubuntu. Recently I discovered
I'm using vim in gnome-terminal (2.26.0): although I use 95% of the time $
While compiling code using vim (not gvim) the output looks fine in the terminal
In using vim, when I start a comment with //, immediately after I type
I'm mainly using terminal vim and/or gvim 7.2 to work on my Perl project
I am currently using VIM in the terminal and have perfect syntax highlighting happening.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.