Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default universal argument emacs (C-u)

Tags:

emacs

If I press C-u C-n the cursor goes down of 4 lines. Can I make the default universal argument to be another number greater than 4?

like image 654
Nisba Avatar asked Oct 15 '25 20:10

Nisba


1 Answers

There might be a better way to do this, but one possibility is to create your own universal argument prefix function. Here is the original function (as you can see 4 is hardcoded in the function):

(defun universal-argument ()
  "Begin a numeric argument for the following command.
Digits or minus sign following \\[universal-argument] make up the numeric argument.
\\[universal-argument] following the digits or minus sign ends the argument.
\\[universal-argument] without digits or minus sign provides 4 as argument.
Repeating \\[universal-argument] without digits or minus sign
 multiplies the argument by 4 each time.
For some commands, just \\[universal-argument] by itself serves as a flag
which is different in effect from any particular numeric argument.
These commands include \\[set-mark-command] and \\[start-kbd-macro]."
  (interactive)
  (setq prefix-arg (list 4))
  (universal-argument--mode))

In your init file, you can create your own custom version of this, and bind it to C-u:

(defun my-universal-argument ()
  (interactive)
  (setq prefix-arg (list 10))
  (universal-argument--mode))

(global-set-key (kbd "C-u") 'my-universal-argument)

However, see @Drew's comment below about why this might not be a great idea, and may have undesired/unexpected consequences.

Also, keep in mind that you can press C-u multiple times as a prefix argument to multiply the repetitions by 4. For example, using the original default of 4, C-u C-u C-n will move down 16 (4*4) lines, and so on.

like image 164
elethan Avatar answered Oct 18 '25 14:10

elethan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!