Vim How to turn off this screen and go to another screen - vim

I used the :term command in Vim.
but i can't escape from that.

While you are typing in the terminal, you are in the "terminal" mode. You can press <C-\><C-N> (Ctrl+\, and then Ctrl+N) to enter the "normal" mode. After that you will be able to switch the windows, with e.g., <C-W> j.
You can read :help terminal-input about this. In particular, it explains how to use Esc (instead of <C-\><C-N>) to escape the terminal mode if you want.

Related

How to bind a key to autocompletion in nvim's terminal mode?

I would like to bind CTRL-N in nvim's terminal mode to autocomplete, just like CTRL-N in insert mode. I don't know command what CTRL-N is bound to in insert mode, so I am not sure how to bind it to the same key in another mode. I am new to Vim and might be confused by emacs concepts here.
The vim completion only works in insertmode, its not possible to open the completion menu in other modes.
the terminal mode however does allow you to remap keys so to make <C-n> activate the shells completion system one would add to init.vim
tnoremap <C-n> <Tab>
this might however not be what you asked for.
your asumption is right your in terminal mode. The autocompletion feature of vim doesnt work in the terminal as its a special kind of buffer that can not be edited. There are plugins though that create a pseudo terminal where the completion menu can be used see
https://github.com/Shougo/vimshell.vim

Screen command disable the control key ctrl-a to use it in vim?

I sometimes open vim with screen linux command but since ctrl-a is considered as control key I cannot increment numbers using the same combination inside the editor.
I don't want to remap entirly ctrl-a but is there a way to disable it so I can use it in vim ?
In screen, you can pass on the prefix key via Ctrl-A followed by a (cp. here). In tmux, this would be Ctrl-b Ctrl-b. Either can be adapted in the tool's configuration file.
Alternatively, you could remap the increment inside Vim, e.g. by putting the following into your ~/.vimrc:
noremap <C-q> <C-a>
You can remap screen to use a different escape if you want. I use Ctrlt.
In .screenrc:
escape ^Tt
This will map the screen metacharacter to Ctrlt. And it also maps the literal sequence of Ctrlt + t to send a Ctrl-t through to the application running inside screen.
This would free Ctrla so screen will not be using it, and it will be passed through to Vim.

How bind a key to execute a tmux command in Vim Normal mode?

I use the tmux terminal multiplexer and I have this simple layout:
I have a Vim pane for code editing and a terminal for building and searching the code and other stuff.
As you may know when I'm in Vim pane I can press Ctrl+BZ to zoom the Vim pane and press it again to zoom back to the original layout.
Now I want to know whether it's possible to bind Esc in Vim's Normal mode to send Ctrl+BZ to zoom the Vim pane?
Something like other IDEs that pressing Esc will hide everything except the code editor?
You can use :!<cmd> from vim to pass <cmd> to the shell, so:
:!tmux resize-pane -Z
will toogle the zoomed state of vim's pane.
Then you just have to remap Esc:
:nnoremap <Esc> :!tmux resize-pane -Z<CR><Esc>
This however will toogle the zoomed state every time you press Esc (hence actually revealing other panes half the time).
I'm guessing you want vim to stay maximize, so (credits to this post for identifying if a pane is zoomed):
:nnoremap <Esc> :silent! exec "!if \\! tmux list-panes -F '\\#F' \\| grep -q Z; then tmux resize-pane -Z; fi"<CR>:redraw!<CR><Esc>

vim: Use ctrl-Q for visual block mode in vim-gnome

I use vim on windows and linux. On linux I would like to set ctrl-Q to visual block selection, but still maintain behave mswin which sets ctrl-v to paste.
How can I keep behave mswin and use ctrl-Q for visual block mode?
edit: I though mswin would also map ctrl-Q to visual block mode, but in vim-gnome ctrl-Q does nothing
first of all, I highly recommend you to forget the windows vim shortcuts if you work on a linux box. such as: ctrl-v, ctrl-q, ctrl-c ...
well you must think this isn't the answer to your question. now I post the "answer".
to make ctrl-q work as ctrl-v (block selection) on a linux box, you have to tell, you work with gvim or vim in terminal.
Gvim
If it was gvim, it is easier, just create a mapping, like:
nnoremap <c-q> <c-v>
Terminal Vim
If you want to make <c-q> work in your terminal vim, you need to understand the default <C-q> has special meaning in your terminal settings.
In your terminal, pressing <c-q> will sent stty start signal. This is important when you first stop your terminal output scrolling(by ctrl-s), and then you want to resume. That is, in terminal vim, if you pressed C-q, it will be captured first by terminal. You can of course change that rule, by disable the stty start definition. like:
stty start undef
you could add this to your .bashrc file (I assume you were using bash) if you want to make it as default.
with this line executed, you can create the same mapping nnoremap <c-q> <c-v> in your vim, and pressing <c-q> in normal mode, vim is gonna enter block-wise selection mode.
After all, again, I suggest you forget the windows mapping if you work on linux box.
If you don't want to change your terminal settings (stty start undef to allow using ctrl q as mentioned in Kent's answer) to be able to use ctrl v for paste, you can make ctrl v paste only in visual and insert modes, and make it block select in normal mode:
" Paste from clipboard when in insert mode.
imap <C-V> <ESC>"+gpa
" Paste from clipboard when in visual mode. (Replace whatever is selected in visual mode.)
vmap <C-V> "+gp
You can also copy to the clipboard from visual mode:
" Copy selection to clipboard when in visual mode.
vmap <C-C> "+y

Ctrl-W in vim dont work in insert mode in terminal

when I use Ctrl-W (or Ctrl-H) in insert mode it does nothing. In gvim with the same vimrc works. I'm using Ubuntu 10.4 with gnome, what may be wrong?
Try adding to your .vimrc: set backspace=indent,eol,start
Type this from normal mode:
:verbose mapC-vC-wEnter
This will tell you two things:
you will see what your terminal emits for C-w (it is shown on the vim command line before you press Enter)
it will tell you whether C-w has any mappings in any mode
it will tell you where the mapping comes from
Subsequently look at
:verbose iabbrev
to see whether abbreviations are in the way
just try type "i" or "a"
maybe you terminal has reserved these key binds?

Resources