I have a few mappings in vim for moving between splits set in my .vimrc,
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
All of these work except for <C-j>, which I suspect is being remapped in one of my plugins. I'd like to find out where, but I'm not sure how. Is there a way to find "where was <C-j> last mapped?"
:verbose nnoremap <c-j>
should help.
Related
New update of plugin ideavim make my remap not working, how can I resolve it ?
He now make some tab indentation, I don't realy understand what is going on.
I just want to move on previous word typing <C-h> & <C-l> to move on next one.
Here is my .ideavimrc file:
" -------------------------------------------------------------------------------
" Navigation
" -------------------------------------------------------------------------------
" Go to next/previous word
nnoremap <C-h> <b>
nnoremap <C-l> <w>
vnoremap <C-h> <b>
vnoremap <C-l> <w>
nnoremap <C-S-h> <B>
nnoremap <C-S-l> <W>
vnoremap <C-S-h> <B>
vnoremap <C-S-l> <W>
" Insert Mode
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
Someone find the solution here:
Github forum
Help! My vim ui is weird. It is hard to explain in word, please see the picture.
Try cleaning the search register:
:let #/=""
I have some mapping to temporarelly disable hlsearch, actually it toggles it, wich is more convinient, in my humble opinion.
nnoremap <silent> <c-l> <ESC>:set hls! hls?<cr> :call clearmatches()<cr><left><c-l>
inoremap <silent> <c-l> <C-o>:set hls! hls?<cr> <C-o>:call clearmatches()<cr>
vnoremap <silent> <c-l> <ESC>:set hls! hls?<cr> <bar> gv :call clearmatches()<cr>
I have the following in my .vimrc
nnoremap <c-h> zh
nnoremap <c-j> <c-e>
nnoremap <c-k> <c-y>
nnoremap <c-l> zl
and nmap reports the following mappings
n <C-H> * zh
n <NL> * <C-E>
n <C-K> * <C-Y>
n <C-L> * zl
The main problem I have is that <c-h> hasn't actually been remapped to zh. <c-h> still acts as the default behavior, which just moves the cursor left.
I've done this in a clean .vimrc file so it's not due to a plugin collision. This is happening with vim 7.4 on a redhat 7.2 system that I remote into from putty. I've tried to replicate this on my windows machine using WSL but it works as expected there.
The minor problem is the second row of nmap, why does it say <NL> instead of <C-J> The mapping seems to be behaving as expected.
I have in my .vimrc the following lines, which lets me switch windows with ctrl+hjkl:
nnoremap <C-h> <C-W>h
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-l> <C-W>l
These are fine for my desktop computer, but on my netbook, I want to have the active window completely fill the tiny screen. This means typing ctrl+w _ and ctrl+w | after each window change. The logical step would be to add those keystrokes to the mapping, yielding:
nnoremap <C-h> <C-W>h<C-W>_<C-W>|
nnoremap <C-j> <C-W>j<C-W>_<C-W>|
nnoremap <C-k> <C-W>k<C-W>_<C-W>|
nnoremap <C-l> <C-W>l<C-W>_<C-W>|
But that fails, consistently, when in a mapping, despite working when I simply type the required keys; and (as I have set 'showcmd') it seems to leave a trailing <C-W>.
I have also tried using :wincmd:
nnoremap <C-h> :wincmd h<cr>:wincmd _<cr>:wincmd |<cr>
nnoremap <C-j> :wincmd j<cr>:wincmd _<cr>:wincmd |<cr>
nnoremap <C-k> :wincmd k<cr>:wincmd _<cr>:wincmd |<cr>
nnoremap <C-l> :wincmd l<cr>:wincmd _<cr>:wincmd |<cr>
But that complains about trailing <cr> whenever my vimrc is sourced, so I'm not going to pursue that further without more research.
Any ideas?
Try using <Bar> instead of |. ie:
nnoremap <C-h> <C-W>h<C-W>_<C-W><Bar>
nnoremap <C-j> <C-W>j<C-W>_<C-W><Bar>
nnoremap <C-k> <C-W>k<C-W>_<C-W><Bar>
nnoremap <C-l> <C-W>l<C-W>_<C-W><Bar>
| are used to have multiply commands on one line and you will need to be escaped with a backslash when used literally:
nnoremap <C-h> <C-W>h<C-W>_<C-W>\|
nnoremap <C-j> <C-W>j<C-W>_<C-W>\|
nnoremap <C-k> <C-W>k<C-W>_<C-W>\|
nnoremap <C-l> <C-W>l<C-W>_<C-W>\|
On the other hand | can be useful:
nnoremap xxx :if 1 == 2 | echom "hello" | endif
I have the following one-line text input that's broken into several soft line wraps.
When I press j, I'd go straight to the next hard line, line 2. How do I navigate among soft line wraps?
Use gj to go down and gk to go up by visual lines instead of hard lines.
put that to your .vimrc:
map <silent> <Up> gk
imap <silent> <Up> <C-o>gk
map <silent> <Down> gj
imap <silent> <Down> <C-o>gj
map <silent> <home> g<home>
imap <silent> <home> <C-o>g<home>
map <silent> <End> g<End>
imap <silent> <End> <C-o>g<End>