I have 2 files opened in a vertically split window. I call term_start() and get results in a split window below. I use something like this:

:let foo=term_start("some_script", {'hidden':1, 'term_finish':'open', 'term_opencmd':'botright split +b%d'})

This works great, but often times the script output cannot fit into one line, so it is getting wrapped in the terminal window. This is not something you can fix with ":set nowrap". These terminal-inserted line breaks create problems with visualization of script output and with searches in the terminal window. I learned I can avoid this by setting 'termwinsize' option to a big number:

:set termwinsize=0*999

This helps, but it creates a different problem - now every time I call term_start() my active window/buffer is for some reasons getting resized to occupy the entire screen space and leaving just one-character wide window for the other buffer.

I'm using (linux) gvim version 8.1.1561

  • 2
    Welcome to Vi and Vim! Many programs fit their output to the terminal width (though some do not). Generally I find this nice for interactive viewing. If you’re just interested in the output, however, I can suggest a few ways to get the output into a file—often those same programs do no width-fitting when writing to a file.
    – D. Ben Knoble
    Oct 5, 2019 at 2:11
  • Thank you for the quick response. I should have added that I don't want to redirect the output to the file. Vim 8.1 is supposed to have fully functional terminal which I want to use and never leave the vim window :). I don't have control over the output of the script - the lines always exceed the width of the terminal.
    – NikDm
    Oct 7, 2019 at 17:16

1 Answer 1


I know you said you "don't want to leave vim [terminal] window" and "Vim 8.1 is supposed to have [a] fully featured [sic] terminal"—but let's consider that

  1. You have to leave the terminal to do editing; and,
  2. No "fully featured [sic] terminal" that I am aware of prevents programs run in it from doing any line wrapping they want to.

So, I propose the use of a file as intermediary: most programs disable line-wrapping when writing to a file (I'm unclear if this is a result of a lower level stdio routine, or a conscious decision on the part of the programmer). This has the benefit that we're ready to edit—which is why we use vim in the first place.

There are many ways to do so:

  1. :term, run your cmd > file, then Ctrl-w:edit file
  2. :enew | execute "read !cmd" | 0d
  3. :Clam cmd (if you use Clam)
  4. :term, run your cmd, copy the output using term normal mode, paste into :enew, then J or :join the appropriate lines

Consider this a frame-challenge answer—it may be what you wanted, but it might help you or others solve the problem

  • I really appreciate your help - some of the tricks you showed in the previous version of your response were very helpful. For example I didn't know I could do term_start(['sh', '-c', 'ps -eaf | cat'].. .Your response helped me solve some other problems and I want to mark your response as "helpful", but I cannot say that's a "correct answer".I have a very specific problem which I stated in the first post: "my active window/buffer is for some reasons getting resized". Imagine that the output of the script is a table.I want to see a terminal output and and use vim keys to search/scroll
    – NikDm
    Oct 8, 2019 at 16:58
  • @NikDm just to clarify, the original (now deleted) answer was not mine. I do understand what youre asking though; it’s just not as achievable as you want.
    – D. Ben Knoble
    Oct 8, 2019 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.