0

After opening the file

app/controllers/pages_controller.rb

Which has

class PagesController < ApplicationController
   def foo
     puts "foo"
   end

   def baa
     puts "baa"
   end

end

I want to add a function/method to this file, but before that I would like to tell emacs to reorder things so that def foo comes after def baa because of alphabetical order.

1

Marking the region and calling M-x sort-paragraphs RET should do it

sort-paragraphs is an interactive autoloaded compiled Lisp function in ‘sort.el’.

(sort-paragraphs REVERSE BEG END)

Sort paragraphs in region alphabetically; argument means descending order. Called from a program, there are three arguments: REVERSE (non-nil means reverse order), BEG and END (region to sort). The variable ‘sort-fold-case’ determines whether alphabetic case affects the sort order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.