'How to create aliases for the keybindings of ESS-R

I'm using ESS to evaluate R codes inside spacemacs. It has some keybindings to evaluate a line, file, buffer, etc. but the keybindings usually contain 4 key strokes. This is too much. I want to create alises. For instance, map `` ess-eval-line` to so that I can easily evaluate lines. How can I do that?



Solution 1:[1]

I want to create alises. For instance, map `` ess-eval-line` to so that I can easily evaluate lines.

Actually, you could create your own key binding for specific functions you want.

Emacs uses keymaps to record which keys call which commands, the global-set-key function binds, or rebinds, the global keymap. Or you could create keybinding for specific mode with define-key like this:

;; You bind `ess-eval-line` function to keystroke `Ctrl-C` `Ctrl-e` globally
(global-set-key (kbd "C-c C-e") 'ess-eval-line)

;; You bind `ess-eval-line` function to keystroke `Ctrl-C` `Ctrl-e` for ess-r-mode
(define-key ess-r-mode-map (kbd "C-c C-e") 'python-switch-to-python)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ramsay