I have a line of code in emacs:
<tab><tab>int i = 0;<cursor>
If I click Ctrl-a, it will move to the beginning of line:
<cursor><tab><tab>int i = 0;
But I want to create an elisp function, that will ignore any indentation at the beginning:
<tab><tab><cursor>int i = 0;
How to do that?
M-m runs the command back-to-indentation, which is an interactive compiled Lisp function in `simple.el'.
It is bound to M-m.
(back-to-indentation)
Move point to the first non-whitespace character on this line.
(defun beginning-of-line++ ()
(interactive)
(if (bolp)
(back-to-indentation)
(beginning-of-line)))
(global-set-key (kbd "C-a") 'beginning-of-line++)
Then, If you click C-a, the cursor will move to the beginning of line, then click C-a again, the cursor will go back to indentation. The successive C-a will toggle replace the cursor between beginning of line and indentaion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With