4

After attempting to use vim a number of times, I'm always been put off by its default key bindings. After some research, I decided to remap the default keys to more sane ones (at least for my tastes). I have a few questions about changing bindings that I could not find answers to through Google.

  1. Is there a way to map a key to an action rather than another key. For example:
    :noremap a h
    will bind the a key to move the cursor left. Is there something along the lines of
    :noremap a move-cursor-left
    or
    :noremap a :move-cursor-left<Enter>
    so I can read my config file afterwards?

  2. Is there a way to unbind all of the default key bindings? I've tried :mapclear but it doesn't seem to work, although it might just be clearing non-default bindings. Unmapping every key manually is not an option. If possible, I would like to export the defaults to a file so I can edit them as I need.

  3. Is there another language I can use to write my own commands for vim other than vim-script? I haven't actually looked into this one so much though. If I can bind an external executable to a command, that would be good enough.

  4. I haven't given up on vim although I would like to ask if there are any vim-like alternatives out there. My Google searches came up with nothing actively developed. If the above cannot be done, or reasonably hacked together, I would like to find a fully configurable, modal, command line text editor that can.

Lindenk
  • 458
  • 2
  • 6
  • 14
  • 6
    1. No 2) No 3) python, ruby, lua, maybe others. However you should still understand vimscript. (Some things are just easier in vimscript) 4) Take a look at emacs with evil mode. – FDinoff Jun 25 '14 at 19:37
  • 3
    You may find [this answer useful](http://stackoverflow.com/a/1220118/717124). – mMontu Jun 25 '14 at 19:55

2 Answers2

5

The command set of vi / Vim has 40 years of wisdom encoded into it; completely changing it is a bad idea. I can only repeat the reference to this answer from the comments; that should convince you (to accept this, or choose another editor).

Give the default commands another try. It'll take some time to get used to, but most Vim users swear by these. It's fine to make minor adjustments "for personal style": careful evolution, but not revolution. Also, some people with odd keyboard layouts (like Dvorak or Colemak) swap several keys for convenience.

The move-cursor-left is just h; aided by the excellent :help, you should be able to "read" your remappings just fine.

In general, even though it's possible to write extensions / plugins in integrated languages like Perl, Python, Ruby, etc. (based on support for them compiled into the Vim binary), you won't get around learning some key Vim internals and parts of Vimscript. If you don't feel comfortable at all about this, I'd suggest to use another editor. Unfortunately, with your requirements of full extensibility (and probably broad acceptance and platform support), there's only one serious alternative: Emacs (which cannot only be turned into everything but a kitchen sink, but also into a modal editor, too).

Community
  • 1
  • 1
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • 5
    "Use the default layout" is an acceptable answer only if using QWERTY. Back to Emacs. :) – Law Feb 26 '19 at 12:42
  • 7
    I have the problem what I use two editors: "less" and "vim". And hence I mistakenly hit "q"-key to quit vim -- which starts the recording... So, "having 40 years of experience" says in *no way* that they know, how other people use the tool, and hence is just a bad excuse to not allow remapping.... – fex Apr 30 '20 at 06:02
  • 1
    @fex: less is not an editor, just a pager (but you can turn Vim into your preferred pager, and this would solve your problem). I don't expect different sets of applications to have the same key bindings (apart from common conventions of a platform like Ctrl-C, Ctrl-V - but what "common" means already is a difficult philosophical question). Finally, nothing in my answer explicitly _disallows_ remapping; a thorough remap is just _discouraged_. – Ingo Karkat Apr 30 '20 at 09:02
  • 2
    It doesn't have "40 years of wisdom". It was designed at a time when there were no mice or arrow keys. That's like saying don't use a smartphone because the rotary dial phone has decades of wisdom in its design. Vim is a terrible text editor let alone programming IDE by todays standards. – Alex Jun 09 '20 at 16:25
  • Well sir.... `j` is on left, `k` is on right, but `j` moves down, and `k` moves up, while `{` `}` are opposite, same with `[` `]` #changemymind – Grzegorz Krug Nov 26 '20 at 13:58
3

(i know this question is old)

you can reset the binds by just over-writing them

on vim you can use many <things> (idk the name)
e.g.
<Up> = Up-arrow-key
<C-f> = Ctrl, f
<A-Down> = Alt, Down-arrow-key
<Esc> = Escape-key

it's possible to remap the hjkl keys to wasd like this:

nmap w <Up>
nmap a <Left>
nmap s <Down>
nmap d <Right>