Skip to content

Instantly share code, notes, and snippets.

@littlemove
Created March 18, 2016 11:40
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save littlemove/5c55dfe0bb724f4420c0 to your computer and use it in GitHub Desktop.
Save littlemove/5c55dfe0bb724f4420c0 to your computer and use it in GitHub Desktop.
Spacemacs: Code folding for ruby-mode
;; Code folding
(add-hook 'ruby-mode-hook
(lambda () (hs-minor-mode)))
(eval-after-load "hideshow"
'(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
ruby-forward-sexp nil)))
(global-set-key (kbd "C-c h <left>") 'hs-hide-block)
(global-set-key (kbd "C-c h <right>") 'hs-show-block)
(global-set-key (kbd "C-c h <up>") 'hs-hide-level)
Copy link

ghost commented Mar 21, 2017

Thanks. It works perfectly fine.

@harisr92
Copy link

harisr92 commented Jul 7, 2018

Thanks a lot. Its working

@gondalez
Copy link

Thanks!
I found removing "class" "module" makes evil-close-folds (z m) behave as I was expecting.
i.e. fold all children of a class or module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment