Forum Discussion
Getting powershell to scroll horizontally instead of word wrap
Is it possible to get powershell to horizontally scroll for long lines of text instead of having them wrap automatically to the next line?
I'm running python, and if you're familiar with python dataframes you can think of it like a speadsheet. I'm having python output many columns, and right now it's wrapping the output to separate lines. Think of having a sheet in excel where for more columns instead of having a horizontal scroll excel wraps it - it's very unreadable.
Right now, I have to redirect my output to a .txt file and then open in notepad, where I can horizontally scroll without word wrap, to see the output in a readable fashion. However, if I could make powershell horizontally scroll instead of wrapping, this would save me a step.
Alternately, if not possible in powershell but possible in plain old command prompt I can run python in the command prompt. However, I'd prefer not to as I can't SSH into remote servers from plain command prompt, and sometimes I need to run python remotely so it would be useful to do it in powershell, thanks.
9 Replies
- LainRobertsonSilver ContributorHi, Taras. Try the following, where in this example, I've used a buffer width of 256. $host.UI.RawUI.BufferSize = [System.Management.Automation.Host.Size]::new(256, ($host.UI.RawUI.BufferSize.Height));Note: This is only worth using under the default shells. If you try it under Windows Terminal, it creates issues as Windows Terminal suppresses the horizontal scroll bar. Cheers, Lain - sawtooth500Copper ContributorI tried using both Get-Content and $host.UI.RawUI.BufferSize = [System.Management.Automation.Host.Size]::new(256, ($host.UI.RawUI.BufferSize.Height)); neither gave me a horizontal scroll. To clarify, I do NOT want it to wrap, I want it to horizontally scroll instead of wrapping.- LainRobertsonSilver ContributorAre you using the standard shell? I've tested the standard shells for both Windows PowerShell and PowerShell and I do get the horizontal scroll bar as show below. Given you said you wanted a value of 7,000, you might want to try that instead of the 256 value I was using, since if your current width is greater than 256 characters, you wouldn't expect to see a horizontal scroll bar. Windows PowerShell initial screen set to a display width of 120 charactersWindows PowerShell screen after running the buffer change command (set to 256 characters width) showing horizontal scroll barThe PowerShell default shell behaves the same way, so I haven't bothered including the almost-identical screenshots from it. Cheers, Lain 
 
 
- Do you want to review the output and do nothing else with it? In Windows Terminal, you can resize it to fit your whole screen, but the output will be wrapped to the horizontal length of your monitor.- sawtooth500Copper ContributorI do just want to review the output and nothing further, however I can't resize the window wide enough. I'd probably need 5000-7000 pixels of width to view it all without wrapping, that's too much for one or even two screens, hence why I want to see if it's possible to get a horizontal scroll with no wrap.- sawtooth500 If you use PowerShell ands store something in a variable, you can pipe and wrap it using $variable | Format-Table -Wrap. If you use Get-Content c:\temp\xyz\123.txt, it should wrap it for you. - Example of using -Wrap, first output was without, then I edited the script and then you can see the difference.