When using vim or less in gnu screen, quitting vim or less leaves a lingering imprint - gnu-screen

On my new Ubuntu system, I start a screen session and edit a file in vim or view it in less. After I quit, the screen doesn't redraw itself, but simply scrolls up to show a command line under all the stuff I was just viewing in vim or less.
How can I change this so that quitting vim will return me to the screen the way it was before I invoked vim?

screen's altscreen (alternate screen) feature is turned off by default.
Add this to your .screenrc:
altscreen on
See: http://www.gnu.org/software/screen/manual/screen.html#Redisplay

This is caused by your termcap for screen being incomplete. (This seems to be a really common problem.) Vim doesn't know the sequence for restoring the screen, so it just leaves it like it was.
You can work around this problem by setting vim's term option (or the TERM environment variable before you start vim) to a terminal that's "screen compatible", like xterm. eg:
TERM=xterm vim
or (in vim):
:set term=xterm
You can set the t_ti and t_te options in vim to the right codes. See :help xterm-screens in vim for more details.

Related

How to use the terminal tabs feature in mintty/MSYS2?

According to https://github.com/mintty/mintty/issues/944 since mintty 3.5.1 there should be a tab bar where you can open multiple tabs with terminals in parallel. For that reason I performed an installation of MSYS2 which includes mintty 3.5.1, as this seems to be the way how to use the mintty. (I verified this with invoking mintty with -V.)
However, I do not find no possibility for opening and/or managing tabs in the UI.
My requirement: I would very much like to have tabs for organizing terminals in parallel.
My question: What's going on here? Did I miss something? Do I need to execute the mintty/MSYS2 with some special commad line options? How can I enable tabs?
You could use --tabbar option when staring minnty. see here for more information.
It was difficult for me to figure out how to turn this feature on. The answer is sprinkled through the comments of this issue, but not in one place. Therefore I'm posting this to save time for others. Here's how you turn the feature on:
Add --tabbar=4 or --tabbar to the windows shortcut that opens mintty:
The 4 is documented here:
no geometry handling; terminal session windows are separate [default]
sync. position/size when switching/launching/closing a session
sync. also when window is moved or resized
sync. also when window is minimized
sync. also when window is started separately
If you'd like to create new tabs with ctrl-shift-t, close tabs with ctrl-shift-w, switch to previous tabs with ctrl-shift-tab, and switch to next tabs with ctrl-tab, add -o "KeyFunctions=t:new-window-cwd;w:close" as an option to that same line.
Personally, I'd like to have ctrl-t/w open and close tabs, respectively, but the only way I've figured how to do that is to add this option: -o CtrlExchangeShift=yes. The problem is, that changes all ctrl-shift commands to become ctrl commands. That means ctrl-r no longer searches bash history.
When you run the shortcut and create some tabs, mintty will look like this:

Intellij IDEA terminal running oh-my-zsh not correctly mapping these specific keys

Environment:
MacOS
Intellij IDEA Terminal
oh-my-zsh
While trying to execute a backwards or forwards word jump using the alt-<back arrow> or alt-<front arrow> combination, I get OD or OC instead. I've tried:
A picture of my settings in IDEA
"shell integration" in idea terminal settings on and off. This seems to only remove the O from the output.
"Override IDE shortcuts", as well as various others on this screen
sourcing a new .inputrc to include the jumping keystrokes. this doesn't really make sense, however since if I switch to bash the jumping motion works.
Additional notes:
alt-<backspace> works

PHPstorm scrolling with keyboard

I'am looking for an option to force scroll code when entering with keyboard cursor in example at 5 line from the end.
Default behavior is to scroll code when entering 1st or last visible line of code.
I would like to change it even for 10th from the beginning and 10th before last.
It appears the base IDE does not have an option for this. However, the behaviour is available in the IdeaVIM plugin (docs) under the scrolloff option.
'Scroll offset' mode can be enabled for the current session with the command:
:set scrolloffset=10
Add that to your ~/.ideavimrc to make it permanent.
NB: IdeaVIM changes the IDE to behave more like vim*, which may require some re-training.
If you're not familiar with Vim:
Install the IdeaVIM plugin (via Settings → Plugins → Browse Repositores → type 'ideavim' in search)
Restart the IDE
Open a file
Note the caret is a block like █; this indicates 'normal' mode
Press : to enter the 'command' mode
Type set scrolloff=10 then Enter
Scroll around, notice the editor scrolls before the caret gets to the very top (or bottom)
Press i to enter 'insert' mode, and edit your file as usual
Press ESC to return to 'normal' mode
Interactive vim lessons
openvim.com
vim-adventures.com
* It seems difficult to have the plugin only modify the scrolloffset behaviour and leave the rest per the default IDE.
You can set "EditorMoveUpAndScroll" shortcut.

Kate Editor shortcut to Focus/Defocus terminal doesn't work

I'm using Kate as the editor for some programs (Octave and sometimes MySQL).
I really like Kate's functionality, at the moment I've really exploited the link between the editor and the terminal.
I have changed some shortcuts to fit my needs as I replicate the behavior from other programs (it's not a big difference but I mention RStudio, which I also use).
The relevant shortcuts are: Show, Focus, Pipe and Synchronize Terminal. Since I modified Focus Terminal (Ctrl+Volume Off -F1 key-, strange choice but effective because of mentioned similarity with RStudio), it only works one way but it doesn't take me back to the editor. In addition, I noticed that the shortcut name changed to Defocus Terminal.
I'm using Kate version 5.0.0 on KDE Frameworks 5.9.0 and Ubuntu 15.04.
You should set a shortcut to View > Tool Views > Show Terminal, this then works as expected. You may have to save the current session to make it persistent (probably a bug). Invoking the shortcut will then toggle this action.

When calling Vim from Midnight Commander, Ctrl-O makes me stuck in the Midnight Commander panel view

By default, Ctrl-O in Midnight Commander is used to show the console output. In /etc/mc/mc.keymap I have set ShowCommandLine to another keyboard shortcut, and now MC doesn't react to Ctrl-O.
Again, by default, Ctrl-O in Vim is used to cycle through previously accessed files. In my ~/.vimrc, I added map <C-o> <nop> and, just in case, imap <C-o> <nop>. Now, if called directly from terminal or xterm, Vim doesn't react to Ctrl-O either.
Despite this, if I call Vim from the Midnight Commander prompt, and then press Ctrl-O, I end up in the standard two-panel mode of Midnight Commander, and I can't Ctrl-O (nor Ctrl-I) out of it.
Naturally, if I try to start a new Vim task from MC, it now tells me that "the shell is already running a command," and if I simply want to F10 out of MC, it says "the shell is still active. quit anyway?", and if I do so, it, of course, kills Vim in the process.
How do I solve this issue?
What's happening here is that Vim captures Ctrl+O by default for navigating back in the jumplist. When you do :map <C-o> <nop>, Vim still captures the Ctrl+O key sequence; it just doesn't do anything about it. As far as Midnight Commander is concerned, you never pressed those keys; Vim captured the input first. I'm not aware of a way to make Vim stop capturing default key sequences.