Force vim terminal to always show latest output - vim

I am using a terminal inside vim (in a split window). I run my code there using vim-slime.
I love it, except for the fact that the terminal "falls behind": if I run 1000 lines of code, the terminal only shows the output of the first few. I have to manually scroll down (or change to the terminal window and press G) to go to the bottom of the outputs again.
Is there a way to force the terminal to behave as a normal (non-vim) terminal and simply keep up with the last outputs?

Related

How to show proper progress bars in vim command quickfix window

I am using macvim, and when I run a shell command in vim's command mode like:
:! yarn add redux
I don't get proper progress bars, instead I get the following characters:
How can I get the output to show proper progress bars?
Those characters are what gives colors and effects (such as underlining) to outputs in shell. They need escape sequences in order to take effect.
The thing is, MacVim doens't have terminal in it and it doesn't do a good job at emulating one.
It doens't have all the features that a normal terminal would have, and that is why it doesn't support ANSI escape sequence.
There is a plug-in for vim that shows the terminal output in vim itself but like the description says in that page, it is no longer supported.
So if you want that screen to be visualized as they are intended to be, I would suggest you use vim in terminal (I tried the exact same code as yours and it worked fine).

How to split VIM window to show content and enable command

I am currently reading a manual about how to compile and run a program. Currently I have two terminals, one terminal shows the manual, the other terminal is where I follow the instructions and type the command. Is it possible to do those two things in one terminal. Just like show two files in one terminal. I want to read the instruction in the left side of the terminal window and type command in the right side of the terminal window. Any advice?
I don't know what's your problem, having two terminal emulator windows side by side is perfectly acceptable. If you really want to add complexity to your learning experience, you can try one of these terminal multiplexers:
tmux
dvtm
or, if such a thing exists for your platform, a terminal emulator with split windows like:
iTerm (Mac OS X)
Terminator (Linux)
In VIM you can create new "windows"/panes just type
:vnew
For vertical window and
:new
For horizontal window
If you want to know more about windows you can check this or if you want to know more about VIM features you can try this
you can use one of the following
:tabe filename to open a new tab containing filename or nothing for a blank tab.
gt to switch and gT to switch backwards.
:sp to split the current window ^w j to jump down and ^w k to jump up
or :vsp to split vertically (so you can read in the left) ^w h to jump left and ^w l to jump right
all key strokes are in command mode

Blanked terminal in screen when quitting emacs

I use emacs in terminal mode (i.e., launched with the -nw option) in screen. When I quit or suspend emacs, instead of getting back my terminal with the history of previous command and outputs of these commands, I see a blank terminal with only the current prompt showed (*).
This is not the same thing as what would happen with the option altscreen off, as all content from emacs disappears from the terminal.
Things that seem strange to me:
- This does not happen when I run emacs outside of screen
- This does not happen with other full-screen apps such as vim or less
- This does not happen on other computers with the same .screenrc, .bashrc, etc.
The computer on which the problem occurs runs scientific linux, Screen version 4.00.03 and Emacs 23.1.1.
I have no problem on two computers running debian, Screen version 4.00.03jw4 and Emacs 23.2.1.
What could be the reason for this?
(*) Note that what I see is not equivalent to a terminal that has been cleared, as the prompt does not appear on the first line of the terminal but on the line it should be if the history of previous commands and outputs had not been erased, i.e. I see several blank lines, then the prompt.

How to scroll within vim's shell command output?

When I enter a shell command via vim -- e.g., :!rake routes -- I'll get some output and then:
Press ENTER or type command to continue
If I press anything at that point, I am always taken back to the main vim UI. How do I stay in that shell mode for a bit longer, specifically I can scroll back to see all the output of the command?
For terminal vim scrolling is provided by terminal emulator (or terminal multiplexer like tmux/screen if you use it). I.e. if your terminal scrolls when using <S-PageUp> it must also scroll with Vim’s !. Same for mouse wheel (it works for me even if vim was configured to handle mouse on its own).
If have terminal vim and you need to view output after you pressed <CR> then you can use <C-z>/:susp. Both these capabilities will be spoiled with incorrect configuration of either vim or terminal (terminal multiplexer) (i.e. terminal configured not to support alternate screens (which is normally issue for terminal multiplexers rather then terminal emulators: screen requires altscreen on in .screenrc) or vim setting telling vim what to output to the terminal on startup/resume and shutdown/suspend was spoiled).
If you have GUI vim your options are very limited. It is better to follow link provided by #glts or #EricAndres advice in this case as I do not use GUI vim.
:r! [shell command] will read the output from the command into the buffer. So if you open a new buffer then use that command, you can search and scroll through it all you like. See Vimcasts episode 57 for more information.

after quitting VIM editor I am not able to see the original screen contents that were present before entering vim

I want to see the original contents of screen after quitting vim
as they were before opening a file , as of not my file quits but the original display is not there
THanks
The feature of returning screen contents after running a full screen application vs, leaving the contents there, is not specific to vi, but to your terminal emulator. The feature you want to turn on to return to the previous text is often known as 'altscreen'. If you are using xterm as your terminal emulator, this behaviour is default. However if you are running GNU Screen inside of an xterm (or other terminal), you need to add the line
altscreen on
to your ~/.screenrc file. Other terminals that support this feature will have other mechanisms to turn it on and off.
Instead of quitting, you can put vim into the background by typing control-z. This restores the previous screen, but leaves you the editor running 'stopped' with the current file. To get vim back, enter the command
fg %1 at the shell prompt. This brings vim back to the foreground again - at least assuming you only have one stopped job. The command jobs will give you a list of stopped jobs, which you can access by number.
So the work sequence becomes edit, save, control-z, compile, test, fg...
This works on linux, and Mac OS X - YMMV on other Unix variants.
If you are using xterm, then see :help xterm-screens, or ... read that anyway as it describes that your problem should be related to some terminfo setting - probably.
HTH

Resources