Converting from camelcase to _ in emacs

前端 未结 7 1963

Is there an emacs function to convert a camel-cased word to underscore? Something, like:

longVariableName

M-x to-underscore

7条回答
  •  失恋的感觉
    2021-02-05 03:45

    If you want to get complete code using s.el:

    (defun to-snake-case (start end)
      "Change selected text to snake case format"
      (interactive "r")
      (if (use-region-p)
          (let ((camel-case-str (buffer-substring start end)))
            (delete-region start end)
            (insert (s-snake-case camel-case-str)))
        (message "No region selected")))
    

提交回复
热议问题