I'm trying to move the navigation keys in normal mode 1 key to the right and because I have a portuguese layout keyboard the key that's next to L is "ç".
when i try to save
:nnoremap ç l
it gets saved as
:nnoremap ? l
I have tried using (alt + g makes a ç) but that doesn't seem to work.
Thanks
Related
I recently generated tags for my project using Exuberant Ctags following approach 4 at: http://ctags.sourceforge.net/faq.html#15.
After this, I have been able to use the tags, tag and stags command to jump to tags. However, Ctrl + ] i.e. <C-]> does not jump to a tag when pressed.
I read through some similar questions and found that the following might be relevant:
:verbose setlocal iskeyword?
iskeyword=#,48-57,_,192-255,#
Last set from /usr/share/vim/vim74/ftplugin/vim.vim
And
:map <C-]>
No mapping found
My Ctrl and ] keys are working fine. I'm able to type the square brace, and I'm also able to use commands like Ctrl + W h/j/k/l to switch between vim splits.
I have checked inside and outside of screen, and checked my .vimrc and .bashrc as well. My .vimrc is at: http://pastebin.com/GkF416SY
Unfortunately, I remain clueless as to whether Ctrl + ] is getting eaten by some program (PuTTY/bash?) or if there is some other issue. I would really appreciate help in fixing this issue. I'd be happy to provide any further information.
EDIT: I'm using a COLEMAK layout with an ordinary keyboard. The [ key is immediately to the left of Enter.
EDIT 2:
I still have the same problem with the staffanc/cscopemaps.vim plugin turned off and cleaned with PluginClean.
I've ensured that cscopetag is not set by using 'set cscopetag&' within the session. It still did not help.
I tried Ctrl + W } -> this opens the preview window with the tag in it. The problem keeps getting weirder.
EDIT 3:
Following #gregory's advice, remapping to worked. Interestingly enough, mapping to and pressing Alt + ] doesn't work!
Oddly, Alt + \, Alt + / also don't work while remapping. One side's Alt key is sending in the character directly, so I'm forced to use Right Alt.
EDIT 4:
I found the following in the list of mapped keys:
o [% * v:<C-U>call <SNR>13_MultiMatch("bW", "o") <CR>
v [% <Esc>[%m'gv``
n [% * :<C-U>call <SNR>13_MultiMatch("bW", "n") <CR>
o ]% * v:<C-U>call <SNR>13_MultiMatch("W", "o") <CR>
v ]% <Esc>]%m'gv``
n ]% * :<C-U>call <SNR>13_MultiMatch("W", "n") <CR>
I'm not sure, but this may be the cause of the problem. Could you please explain the use of the '%' character here? I took a quick look, but I haven't been able to track it down yet.
On my French AZERTY keyboard, if want want to hit CTRL+], I have to remember where it's placed on a US/QWERTY keyboard. Then, I hit CTRL + this key.
IOW, as I never remember where those keys are depending on the keyboard used, I've mapped CTRL+] to something I can remember: <M-Down>.
I have j/k set to scroll in the autocomplete box as posted in this question: Scrolling in vim autocomplete box with jk movement keys
Now I want to map h to close the box without completion, and l to close with completion. Both should stay in insert mode. How can I do this?
inoremap <expr> h ((pumvisible())?("\<C-e>"):("h"))
inoremap <expr> l ((pumvisible())?("\<C-y>"):("l"))
I can map 'jj' to
imap jj <Esc>
and I can even map letters to tab navigation
map tj :tabprevious<CR>
map tk :tabnext<CR>
But I can't map g to page up (even though spacebar acts as page down)
map <Space> <PageDown>
map g <PageUp>
According to this "When you try to map multiple key sequences, you won't be able to start them with lower or upper case letters ("Too dangerous to map that"), but the punctuation and control characters are fair game." Can anyone confirm this?
If so, how does one assign a function to an unmapped key like 'g'
This isn't answering your question, but I thought it may be helpful to the problem you are having with your RSI. It maps the spacebar to toggle between fast and slow move modes. Normally pressing j or k will scroll down one line. Pressing space will turn on fast move mode, where pressing j or k will scroll down/up 10 lines. Press space again to go back to normal. This will only work in vim, not just plain vi (most "vi" programs are just symlinks to vim anyway though).
It works in both normal and visual edit modes.
To use it, put this code somewhere in your ~/.vimrc file:
map <Space> :call ToggleFastMoveMode()<CR>
vmap <Space> :call ToggleFastMoveMode()<CR>gv
let g:fastMoveMode = 0
function! ToggleFastMoveMode()
let g:fastMoveMode = 1 - g:fastMoveMode
if (g:fastMoveMode == 0)
noremap j j
vnoremap j j
noremap k k
vnoremap k k
else
noremap j 10j
vnoremap j 10j
noremap k 10k
vnoremap k 10k
endif
endfunction
(Edit - original answer suggested native Ctrl-f and Ctrl-b, but answer was updated as the goal here is to avoid using Ctrl and Shift)
A few points to add
Leaving the issue of choosing the right character to you, assuming we chose X for now.
I can think of two reasons why map X <PageUp> isn't working for you.
Your version of vi may not support PageUp/PageDown. If this is the issue then try instead to map to vi's page jumping (B for back, accompanied by for forward) eg. map X <C-b>.
Another other option is that it doesn't work 'as expected'. In vi PageUp/PageDown act on the 'viewport' not the cursor. So if you'r looking at the top of the file, but the cursor is not at the top or won't do anything. PageDown won't 'work' if your cursor is two lines from the bottom either.
To address this you could combine the 'move viewport up' <C-b> and the 'move cursor to the top of viewport' H eg. map X <C-b>H (The opposite being map X <C-f>L). Or specifying the number of lines to jump yourself map X 30k (Op. map X 30j).
Then the issue of choosing the right character to overwrite. Vi has a lot of native commands, so many in fact that only a handful of characters don't do something natively.
So if your goal is to avoid RSI, then of course overwrite something. But make sure to overwrite something that isn't too useful for you personally.
Natively:
f searches for a given symbol on the line you are currnetly on (can be very useful, but not critical I guess)
g on it's own does nothing, but gg moves cursor to top of file. Choosing g may cause issus as vim (not the original vi) will interpret two quick keypresses as go to top of file instead of do two PageUp's.
I want to create mapping that would be trgiiger in normal mode by pressing pp and I want it to execute key sequence ctr w l. How do I do that. I have now sth like this but it doesn't work.
nmap nn <C-w-h><CR>
Thanks in advance
<C-w-h> is not a valid key sequence. If you want to press Ctrl+W and then release and press h, you need the following:
:nmap nn <C-W>h
If you want to press Ctrl+W and then press h without releasing Ctrl (effectively Ctrl+WCtrl+H), you need this:
:nmap nn <C-W><C-H>
I usually create both maps in this situation, because sometimes my fingers lag and I release Ctrl a little later or a little earlier. With both, that's not a worry.
There's no need to add a <CR> to the mapping here.
Although I played with it before, I'm finally starting to use Dvorak (Simplified) regularly. I've been in a steady relationship with Vim for several years now, and I'm trying to figure out the best way to remap the key bindings to suit my newfound Dvorak skills.
How do you remap Vim's key bindings to best work with Dvorak?
Explanations encouraged!
I use one of the more common recommended keybindings:
Dvorak it!
no d h
no h j
no t k
no n l
no s :
no S :
no j d
no l n
no L N
Added benefits
no - $
no _ ^
no N <C-w><C-w>
no T <C-w><C-r>
no H 8<Down>
no T 8<Up>
no D <C-w><C-r>
Movement keys stay in the same location. Other changes:
Delete 'd' -> Junk 'j'
Next 'n' -> Look 'l'
Previous 'N' -> Look Back 'L'
There were also some changes for familiarity, 's'/'S' can be used to access command mode (the old location of the :, which still works).
Added Benefits
End of line '$' -also- '-'
Beginning of line '^' -also- '_'
Move up 8 'T'
Move down 8 'H'
Next window <C-w><C-w> -also- 'N'
Swap windows <C-w><C-r> -also- 'D'
-Adam
I don't find that I need to remap the keys for Dvorak -- I very quickly got used to using the default keybindings when I switched layouts.
As a bonus, it means that I don't have to remember two different key combinations when I switch between Dvorak and Qwerty. The difference in keyboard layout is enough that I'm not expecting keys to be in the same location.
A little late, but I use the following:
" dvorak remap
noremap h h
noremap t j
noremap n k
noremap s l
noremap l n
noremap L N
" easy access to beginning and end of line
noremap - $
noremap _ ^
This basically does the following:
left-down-up-right are all under the default finger positions on the home row (i.e. not moved over by one as in the default QWERTY Vim mappings)
l/L is used for next/previous search result
use -/_ to reach the end/beginning of a line
This seems to work for me...
I simply use standard qwerty for commands and dvorak for insert mode
Here is how to set it up
My rebindings:
noremap h h
noremap t j
noremap n k
noremap s l
noremap j t
noremap l n
noremap k s
noremap J T
noremap L N
noremap K S
noremap T J
noremap N L
noremap S K
Notes:
In qwert, vi has to use 'h', because vi doesn't want to use ';' a non-letter. But
in dvroak, we have 's', so why not take this advantage?
vi uses Caps for relative actions. This is a good design philosophy. So I try to
conform this.
Meanings:
n (Next) -> l (Left) -- "What's left?" resembles "What's next?"
s (Substitute) -> k (Kill then insert)
t (jump Till) -> j (Jump till)
N, S, T are similar.
J (Join lines) -> T (make lines Together)
K (Keyword) -> S (Subject)
L[count] (Line count) -> N (line Number)
B.T.W. L itself goes to the last line, and N is the last letter of fin.
(Thanks for tenzu to point out this.)
P.S. I have used these rebindings for a while. Now I does not use it in vim. I just use the default ones.
Vim ships with an extensive Dvorak script, but unfortunately it’s not directly source-able, since the file includes a few lines of instructions and another script that undoes its effects. To read it, issue the following command:
:e $VIMRUNTIME/macros/dvorak
You can use this to have Vim use Dvorak only in insert mode:
:set keymap=dvorak
This way all of the commands are still in QWERTY, but everything you type will be in Dvorak.
Caveats: Well, almost everything. Insert mode, search mode, and replace mode will all be dvorak, but ex commands will not. This means that you don't have to relearn :wq, but you will need type :%s/foo/bar/gc in QWERTY.
This won't help if you only want to move certain commands, but I found that in my head, "move forward one word" was bound to "move left ring finger up," rather than "ask the typing department where the letter 'w' is and then press it," which made this method much easier for me.