I have mapped Ctrl-j to move to the buffer below. However it was hard mapped to something else so I had to write the first row below to make it mappable at all.
The script below works perfectly, except when I write .sh files. I have bash-support plugin installed.
let g:C_Ctrl_j = 'off'
map <C-j> <C-w>j
EDIT: I have just found out that the problem is in bash-support. Bash-support maps Ctrl-j to jump insert (or something like that) which moves cursor at a predefined point and goes to insert mode. I guess changing that in bash-support script will do the job though I don't like messing with those files.
EDIT2: let g:C_Ctrl_j = 'off' actually turns the csupport plugin jump insert feature.
According to the document of bash-support.vim:
The original meaning of Ctrl-j is 'move [n] lines downward' (see |CTRL-j|). If you are accustomed to use the default and don't like these jump targets you can switch them off. Put the following line in the file '.vimrc' :
let g:BASH_Ctrl_j = 'off'
So that you have to put let g:BASH_Ctrl_j = 'off'
into your vimrc.
Additionally, use nnoremap <C-j> <C-w>j
instead of map <C-j> <C-w>j
in your vimrc.
The latter defines key mappings in Normal, Visual and Operator-pending modes.
The key mappings are also recursively expanded.
It might cause troubles when you define more key mappings.
Ctrl-j (0x0A) is a special character, Line Feed.
There's a good chance that this key-press is not is not arriving at Vim as Ctrl-j (0x0A).
In Vim in a Terminal.app window on my Mac, typing Ctrl-v Ctrl-j displays ^@
, (0x00 or NULL). Whereas Ctrl-v Ctrl-g and Ctrl-v Ctrl-k display ^G
and ^K
, respectively.
I'd suggest using another mapping (or just training yourself to use Ctrl-w j).
I had the same issue, but for a different reason. VIM-LaTeX uses imaps.vim plugin, which also remaps some keys, including Ctrl-j. What worked for me is to set an autocmd
in my .vimrc
:
augroup vimrc
au!
au VimEnter * unmap <C-j>
au VimEnter * noremap <C-j> <C-w>j
augroup END
The VimEnter
trigger makes sure that the remap will executed after vim starts up, and the plug-ins are loaded (if I understand it correctly), so it overwrites the imaps.vim plug-in's maps. The unmap isn't necessary, but it can't hurt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With