jump over imports when opening files
fommil opened this issue · 5 comments
fommil commented
it would be pretty useful to jump to the first non-package, non-import line in a scala file when opening.
hvesalai commented
Hmm... maybe attach something to the find-file-hook
hook that will position the file.
fommil commented
yup, we might have some regex in ENSIME that finds the right place to put new imports... probably the thing we need here.
fommil commented
I can probably cook something up from https://github.com/ensime/ensime-emacs/blob/master/ensime-editor.el#L493
fommil commented
(defun scala-mode:goto-start-of-code ()
"Go to the start of the real code in the file: object, class or trait."
(interactive)
(let* ((case-fold-search nil))
(search-forward-regexp "\\([[:space:]]+\\|^\\)\\(class\\|object\\|trait\\)" nil t)
(move-beginning-of-line nil)))
put it in your scala-mode-hook
fommil commented
(if anybody actually wrote comments in Scala, perhaps we should jump to those as well)