VS Code: Increase the number of Lines shown in the Terminal

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
3 min

banner

# Table of Contents

  1. VS Code: Increase the number of Lines shown in the Terminal
  2. Increasing the terminal buffer size in your settings.json file
  3. Increasing the terminal buffer size for the current project
  4. Where is the Terminal history saved when using VS Code

# VS Code: Increase the number of Lines shown in the Terminal

By default, the VS Code terminal only keeps 1,000 lines in its buffer.

For example, if I run the following JavaScript file that loops 2,000 times, I can only see the last 1,000 messages.

index.js
for (let index = 0; index < 2001; index++) { console.log(index) }

terminal only shows last thousand messages

To increase the number of lines that are shown in the terminal:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Type terminal scrollback and increase the lines using the Terminal Integrated Scrollback setting.

increase number of lines shown in terminal

The setting controls the maximum number of lines the terminal keeps in its buffer.

The default value is 1,000. Note that setting the value too high might consume more memory and slow down VS Code if you work with programs that produce a lot of output.

There is also a Persistent Session Scrollback setting.

persistent session scrollback

The setting controls the maximum number of lines that are restored when reconnecting to a persistent terminal session and is set to 100 by default.

Now that I've set the terminal scrollback setting to 2,000, I can run the following code and see the entire output in my terminal.

index.js
for (let index = 0; index < 2001; index++) { console.log(index) }

terminal buffer size increased

# Increasing the terminal buffer size in your settings.json file

You can also increase the VS Code terminal buffer size directly in your settings.json file.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings json.

  2. Click on Preferences: Open User Settings (JSON)

preferences open user settings

  1. Set the terminal.integrated.scrollback property to the number of lines you want to keep in memory.
settings.json
"terminal.integrated.scrollback": 2000,

If no properties follow, remove the trailing comma.

increase terminal buffer size in settings json

# Increasing the terminal buffer size for the current project

If you only want to increase the terminal buffer size for the current project, edit your local .vscode/settings.json file.

  1. In the root directory of your project, create a .vscode folder.

  2. Create a settings.json file in the .vscode folder.

  3. Add the following code to your settings.json file.

.vscode/settings.json
{ "terminal.integrated.scrollback": 2000 }

increase terminal buffer size for current project

The configuration in .vscode/settings.json overrides any global configuration and only applies to the current project (workspace).

# Where is the Terminal history saved when using VS Code

VS Code uses an external shell:

  • PowerShell on Windows.
  • bash or zsh on Linux and macOS.

The PowerShell terminal history file is located at:

  • %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine

location of terminal history file windows

You can paste the path directly in Explorer as shown in the screenshot.

The path resolves to:

  • C:\Users\YOUR_USER\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline

You can use the type command to read it directly from your terminal.

The following command assumes that the file is named ConsoleHost_history.txt.

cmd
type %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

On macOS and Linux, open your terminal and issue the following command:

shell
echo $HISTFILE

find terminal history file macos linux

You can use the cat command to read the file directly from your terminal.

The following command assumes that the path to your terminal history file is ~/.zsh_history.

shell
cat ~/.zsh_history

You can also pipe the output to the less command to be able to scroll.

shell
cat ~/.zsh_history | less

Press q to quit the interactive command.

I've also written an article on how to change the default terminal in VS Code.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.