Converting from camelcase to _ in emacs

前端 未结 7 1966

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")))
    
    0 讨论(0)
提交回复
热议问题