We’re rewarding the question askers & reputations are being recalculated! Read more.
75

From http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/: When Bill Joy created the vi text editor he used the ADM-3A terminal, which had the arrows on hjkl keys. Naturally he reused the same keys and the rest is history!


60

A common binding you'll see is jj, because it works well for QWERTY layouts if you use home row positioning. inoremap jj <ESC> In that case, to type a literal jj - you should wait for 1 sec (by default) between typing the second character. (see :help 'timeout' for details) There is also c-o which will take you out of insert, letting you do one ...


38

Beside the built-in alternatives <C-[> and <C-c> to <Esc> key cited by others, another popular solution is to remap <CapsLock> as an additional Escape. This both on a Qwerty and Dvorak keyboard. This way you can press Esc very easily with the left little finger, without removing hands from the HomeRow (incidentally, CapsLock is ...


28

The mappings that I use are: inoremap jk <esc> inoremap kj <esc> This way, you can simply hit j and k at the same time, without having to worry about which one you press first.


24

Others have already provided work-arounds, but as for the reason why it happens, I bet you're accidentally pressing Alt+Space. I'm using Xubuntu with the 105-key Finnish keyboard layout myself, so for me, typing { means pressing AltGr+7. I just did a quick test in xfce4-terminal (on the bash command line), and pressing AltGr+Space indeed produces a no-...


21

Nobe4's answer is great, and explains why we use hjkl very well. However, it's really interesting to see the full keyboard, and a lot of strange things about vim make more sense when you can see the full keyboard it was designed on. For example, why does vi rely so heavily on the esc key, when it's in such a weird and uncomfortable place? This is why: As ...


19

You can add an autocommand that replaces non-breaking spaces with regular ones upon saving particular file types, eg. by putting something like this in your vimrc: augroup RemoveSpaces autocmd! autocmd BufWritePre *.css silent! :%s/\%u00A0/ /g augroup end You can tweak it by adding more file types or setting a mark and returning to it after the replace ...


17

As to why these arrows were printed on these keys... it's because they could be used with the control key for local cursor movement. Ctrl-H and Ctrl-J (backspace and line feed) are obvious, and an easy mnemonic even today. Ctrl-K is "vertical tab", but was sometimes used for reverse linefeed on pre-ANSI terminals. The use of Ctrl-L for a non-destructive ...


13

<C-[> and <C-c> are two native alternatives to <Esc>. See :help i_<esc> and :help i_ctrl-c which explains the difference between <C-c> and <Esc>.


13

The 'listchars' option provides a means to make 'list' display non-breaking spaces. It's not set by default, so you probably want to add it. set listchars+=nbsp:‗


12

Try making it a mapping: " Mapping dead keys in normal mode nmap á 'a That way, when Vim gets the accented a, it interprets it as `+a Using nmap allows this to happen in normal mode only; in insert mode or command mode, you'll get the accented a as you'd expect. It is possible to apply this to other keys: nmap à `a nmap Á 'A nmap À `A nmap ç 'c nmap Ç '...


10

As I said in the comments, mappings in are not designed to do what you want to do. An interesting option for this use case is langmap. This option allows to keep the behavior or your keyboard in insert mode and change its behavior in the other modes. To use it Vim has to be compiled with +langmap, you can check that this option is enabled with echo has('...


8

:help langmap You can remap keys in command mode but leave them intact for typing. This means you can use the intent of hjkl - adjacent homerow keys for scrolling - by pressing the positional equivalents on your keyboard. Suppose your layout is Dvorak, then those same keys are htns. h is the same, so we need to map the other three: :set langmap=tj,nk,sl ...


7

Vim has something like this in the form of keymaps. From :help mbyte-keymap: When the keyboard doesn't produce the characters you want to enter in your text, you can use the 'keymap' option. This will translate one or more (English) characters to another (non-English) character. This only happens when typing text, not when typing Vim commands. This ...


7

From :he digraph: Digraphs are used to enter characters that normally cannot be entered by an ordinary keyboard. Running :digraphs will show you the currently defined digraphs. ` is defined as '! and ~ is defined as '?. There are two ways of entering digraphs: <C-k> {char1} {char2} {char1} <BS> {char2} The second method requires :set ...


6

I would recommend keymap, which can solve your trouble. Put these in your vimrc " set keymap=greek_utf-8 set iminsert=0 set imsearch=-1 to disable Greek as a default.You can toggle the option on (Greek) and off (English) using <ctrl>+^ (you can also use <ctrl>+6, it is mapped on key, not on symbol) in insert mode and Replace mode (doesn't work ...


4

As far as I know there is no built-in support for mappings that change based on the time you hold the key. But as the problematic key is Esc, you have some good alternatives: Use Ctrl+[, which works by default (as explained in :help key-codes): <Esc> escape CTRL-[ 27 *escape* *<Esc>* As Esc is a heavily used key in Vim, many ...


4

I would suggest using my plugin vim-easyescape. Plug "zhou13/vim-easyescape" let g:easyescape_chars = { "j": 1, "k": 1 } let g:easyescape_timeout = 100 cnoremap jk <ESC> cnoremap kj <ESC> The problem with a simple map sequence inoremap jj <ESC> is that Vim will pause whenever you type j or k in insert mode (it is waiting for the next key ...


4

You can map Caps Lock to Control without using any external program: In Mac OS X visit System Preferences > Keyboard -> Modifier Keys In Linux execute: setxkbmap -option caps:ctrl_modifier In Windows edit your registry. This brings Control onto the home row, making it easier to press all Control modified strokes, including Ctrl-[ and Ctrl-C which both exit ...


4

In the place where ANSI US has [ and ] Nordic keyboards have å and ¨, of which the latter is really not bindable, since it sends "half a character" and waits for the character to be accented. For example, pressing ¨a outputs ä. One solution would be to "left-shift" the binding to CTRL-å (the key to the right of P). I personally switch between US and ...


4

I think your best bet would be to remap everything that uses s in all modes. You are already aware of the command for normal mode I think, nnoremap. This changes the normal mode mapping only. Once you press a key like c you normally enter operator pending mode. Since you are not in normal mode anymore, the nnoremap has no effect here. Instead you should use ...


4

EDIT @Octaviour's solution is way smarter, you should use it :-) Nonetheless I'll leave this answer here because I worked on it and because it contains some interesting part about the usage of <SID> which can still be interesting to read I believe that actually your problem is more complex than you could think: What you want is not a second layout: ...


4

Short answer Turn off “application keypad mode switching.” Terminal-specific instructions PuTTY (also here): Terminal > Features > uncheck Disable application keypad mode SecureCRT: Session Options > Terminal > Emulation > Modes > Mode switching > uncheck Enable keypad mode switching iTerm: Switch to iTerm2 or see general instructions ...


4

There isn't one single builtin command to open the buffer and position it, I don't believe. Well, it turns out there is. The :botright {cmd} style of commands (e.g. :botright vsplit). If @Mass provides an answer please accept that answer. I'll leave this for informational purposes as the Ctrl-W commands discussed at the end might still be of interest to ...


3

In terminal vi and Vim, alt + single-normal-mode-key will work for quick edits in most terminals. This works because most terminals send the alt modifier as the escape character. For example, when you type alt+k the terminal emulator sends two character to the running program: esc, k. Vi and Vim interpret this as you would expect; it leaves insert mode (...


3

According to Terminator's FAQ: You should set TERM = terminator because it uses a non-conventional terminfo file. You should guarantee that you don't have vim-minimal (or similar) package, because it might not include support for terminfo.


3

Ingo Karkat's answer seems like it was exactly the right solution and has solved my situation. However here are a little bit more verbose instructions for anyone else just getting started with vim's language map functions. First, you need a language map file. As in the Caps Lock example, you'll want to put something like the following in ~/.vim/keymap/...


3

FWIW I use: :map! ;l ^[ :vmap ;l ^[ It feels similar to hitting Return. I use ; as the leader for other Insert-mode mappings too. The only time I've needed to type ';' + letter is when code golfing; I've not had any conflicts otherwise.


3

It sounds like you have something like noremap i d noremap ix ... other mappings starting with i And you are asking that for i the timeout is 0. In that case you would never be able to type any of the ix mappings - so why not just remove them and solve the problem this way? If this is only for visual mode then avoid defining mappings that start with i ...


3

There are special keys <k0> to <k9> and <kPlus>, <kMinus>, <kDivide>, <kMultiply>, <kEnter>, and <kPoint>, which can be mapped separately, e.g., inoremap <k0> Zero inoremap <k1> One ... I checked this with GVim running on Windows 7; the behavior on macOS might be different.


Only top voted, non community-wiki answers of a minimum length are eligible