I'm not sure if this is package-specific (example here is olivetti-mode), but when I try to "remap" with statement:

(define-key olivetti-mode-map (kbd "<f7> ]") 'olivetti-shrink) (for some reason you have also wrap this in eval-after-load, but omitted here)

The old keybinding for the function olivetti-shrink (C-c ]) stays in place, so that I now get two keybindings for the same function. I only want the new key-binding. As a general rule, do you have to map to nilwhenever you want to change the key binding:

Answer?:
According to this tutorial the answer is YES: you have to do it every time.
One workaround is to use use-package which allows you to configure a bunch of options after loading, including keybindings.

1 Answer
1

You are asking to add a key binding for the command, and you are asking to remove a key binding for the command.

You say "every time", but it is not that common to want to replace a key binding with another. In any case, if you want to do that a lot you can easily define a macro that does it: carries out a replacement by an addition and a deletion.

(On the other hand, it is common to want to replace the command that is bound to a given key by another command. For that Emacs lets you either (1) use [remap COMMAND] in define-key or global-set-key or (2) use substitute-key-definition.)