while on :vert term, I would like to switch between terminal and vim with alt+q instead of ctrl+w+w
how would I do that? What do I write after :noremap in .vimrc?
thank you in advance
Try:
nnoremap <M-q> :vert term<cr>
Related
I can yank a visual selection into the X clipboard in vim using "+y - I would like to map this to something more convenient. I tried mapping to Ctrl-y by adding
:vmap <C-y> \"+y to my .vimrc but it doesn't work. How can I do this?
In ~/.vimrc add:
vnoremap <C-y> "+y<Esc>
or Ctrl-Shift-y:
vnoremap <C-S-y> "+y<Esc>
Make sure that your terminal does not already use that shortcut. For Gnome terminal see this.
Tip: if using default Gnome terminal shortcuts, paste that C-y yanked chars with: C-S-v in terminal or just C-v elsewhere.
The problem was that I was escaping the " character. This, it seems, is wrong in this context. simply:
:vmap <C-y> "+y
works, as expected.
To open a new file in a horizontal split I can do:
:sp file.py
Is there a way to open my native terminal (I'm on mac) in the same way? Something like:
:sp terminal?
:terminal is what you want.
See :help terminal
My vim mappings
nmap <leader>t :term<cr> " horizontal split
nmap <leader>tv :botright vertical terminal<cr> " vsplit
I'd like to be able to use the same shortcut to jump to a file in NERDTree and close NERDTree. I have no experience with VimL and could use some help.
Add the following to you vimrc
set autochdir
noremap <F2> :NERDTreeTabsToggle<cr>
The first command will automatically change the current directory to be the same the same as the file you are editing.
The second command will then set F2 to toggle toggles NERDTree on/off for all tabs. you can use any key i prefer F2.
Just say you want to do this with <leader>n:
" This in your ~/.vimrc
nnoremap <leader>n :NERDTreeFind<CR>
" This in ~/.vim/ftplugin/nerdtree.vim
nnoremap <buffer> <leader>n :NERDTreeClose<CR>
Substitute whatever you want for <leader>n.
When I use the arrow keys in vim in insert mode I get letters inserted instead of movement.
Up produces an A
Down produces a B
Left products a D
Right produces a C
Does anyone know what would cause this?
Thanks in advance
If these keys work fine in normal mode, but do not in insert then you must have some mappings to the first one or two characters (normally <Up> is either <Esc>[A (terminals that use CSI) or <Esc>OA (xterm)). Try checking out output of
verbose imap <Esc>
, there should be not much mappings starting with <Esc> in insert mode (I have none, for example). I can say, that with arrow keys working normally in insert mode, using
inoremap <Esc> <Esc>
produces just the same behavior as if you had problems with terminal recognition or had 'compatible' set.
Your vim seems to be starting in the vi compatibility mode. Do this
Open Vim editor,
Get the path of your home directory by typing :echo $HOME
Check if you have .vimrc file in $HOME location,(if you don't have create it)
Add the following line line to .vimrc file
:set nocompatible
Find more solutions for the same problem here ( Especially if your problem is terminal related, the re-mapping of keys solution might work for you )
The following worked for me. Just put it in your .vimrc
:set term=cons25
Open Vim editor.
Get the path of your home directory by typing: :echo $HOME.
Check if you have .vimrc file in $HOME location, and if you don't have create it.
Add the following line line to .vimrc file: :set nocompatible
Reference: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
None of the answer here worked for me. I'm in Linux, with konsole/yakuake terminal and tmux. This fix works for me:
nnoremap <silent> <ESC>OA <ESC>ki
nnoremap <silent> <ESC>OB <ESC>ji
nnoremap <silent> <ESC>OC <ESC>hi
nnoremap <silent> <ESC>OD <ESC>li
inoremap <silent> <ESC>OA <ESC>ki
inoremap <silent> <ESC>OB <ESC>ji
inoremap <silent> <ESC>OC <ESC>hi
inoremap <silent> <ESC>OD <ESC>li
I am using gvim under linux and I really love it, the problem I have with it is that Shorcuts like Crlt+C doesn't work...
I added the following code to my gvimrc but it doesn't have any effect :/
nmap <C-V> "+gP
nmap <C-V> "+y
nmap <C-A> ggVG
nmap <C-Z> u
nmap <C-Y> ^R
The problem is not that the shortcuts don't work, rather than that you don't know what the shortcuts are supposed to do.
It might help for you if you add behave mswin to your .vimrc. It remaps many key bindings to behave more like other programs.