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.
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.
So I am debugging my php app with xdebug and https://github.com/joonty/vdebug/ as my vim plugin. When I hit get the debug running i get 4 windows. In other vim plugins I was able to switch between these windows so i could scroll up and down in case the data became too big. I can't seem to figure out how to do this.
Anyone know how to switch between windows with xdebug using vim?
If it is just split window, you can read about it here
:h window-move-cursor
To make it more simple put this mapping into your vimrc
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
Now just press ctrl-J to get to window below current one, etc.
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 have created the following mapping in my vimrc file:
noremap <C-p> ! firefox -new-tab http://php.net/<cword><C-m>
The problem is that it proceeds to delete the line under the cursor.
How would I make this mapping work correctly?
If I understood what you're trying to do the following should work:
nmap <c-p> :!firefox -new-tab http://php.net/<c-r>=expand('<cword>')<CR><CR>
See docs for further information.
You are using noremap which means that it triggers:
in normal mode
in visual mode
in operator-pending mode.
You should use nnoremap or xnoremap instead. Also, note that ! is a shortcut for :.! in normal mode (acts on current line) and for :'<,'>! in visual mode (acts on current visually-selected lines). If you don't want that:
nnoremap <c-p> :!firefox ...
xnoremap <c-p> :<c-u>!firefox ...
While CtrlX works fine in vim under windows, CtrlA selects all (duh).
Is there a way to increment a number with a keystroke under windows?
You can make CtrlA to increment in windows by opening up the 'mswin.vim' file in your vim directory and finding the section that looks like:
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
Comment out all of these lines as follows:
" CTRL-A is Select all
"noremap <C-A> gggH<C-O>G
"inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
"cnoremap <C-A> <C-C>gggH<C-O>G
"onoremap <C-A> <C-C>gggH<C-O>G
"snoremap <C-A> <C-C>gggH<C-O>G
"xnoremap <C-A> <C-C>ggVG
and the CtrlA keystroke will increment.
This is a pretty nice option when your keyboard doesn't have a real number pad.
Try Ctrl-NumPad + ?
(from here)
I realize that this is an old question, but I ran across another option today based on the following question. Making gvim act like it does on linux will allow CTRL-A to work as you expect it to:
how to make gvim on windows behave exacly like linux console vim?
There is a section of the _vimrc that has the following items. These cause many of the control characters to act like they do on Windows.
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
I commented out (with ") the mswin lines and the set nocompatible line. From there, I added set compatible. This causes gvim to act like it does on linux. Thus, mine looks something like:
set compatible
source $VIMRUNTIME/vimrc_example.vim
"set nocompatible
"source $VIMRUNTIME/mswin.vim
"behave mswin
I just learned this trick today, so if I'm not completely correct in my information, please let me know.
I modified TMealy's solution so that CtrlA still selects all (I find this useful), while CtrlI increments (also useful).
noremap <C-I> <C-A>
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
A similar problem occurs under GNU/Linux when using Vim with mswin.vim.
Remapping Alt+X to Ctrl+A prior to evoking mswin.vim solved my issue.
execute "set <A-x>=\ex"
noremap <A-x> <C-A>
source $VIMRUNTIME/mswin.vim
behave mswin
Now, Alt+X and Ctrl+X respectively increase and decrease numbers in Vim.
Mapping to Alt key combinations is often not evident in Vim; read more about this here.
I am using cygwin terminal + screen, so <c-a> is captured by the terminal multiplexer. I used this mapping:
:noremap <c-i> <c-a>
It seems that the CtrlA got mapped somewhere in startup.
As suggested before, use:
unmap <c-x>
I would use unmap, not nunmap.