Often while coding I need to align comments etc. to specific columns. It is useful to have a key combination/command that will delete everything from cursor to the next non-white character.
M-\ runs the command delete-horizontal-space, which however deletes white space to left of cursor as well, which is not the desired outcome! Is there any existing command that will do this?
With some trial and error cooked up the following function, which seems to do what I want.
(defun del-ws-to-right () "Delete all spaces and tabs from point to next non-white char." (interactive) (save-excursion (let* ((orig-pos (point)) (numchrs (skip-chars-forward " \t")) (end-pos (+ orig-pos numchrs))) ;(message "orig-pos : end-pos = %d : %d" orig-pos end-pos) (delete-region orig-pos end-pos) ) ) ) (global-set-key (kbd "C-.") 'del-ws-to-right)
The elisp code for delete-horizontal-space etc. look more complicated! Just wonder if there is any gotchas here?!