Skip to content

The smart-newline.el provide a stress-less newline command for programmer.

Notifications You must be signed in to change notification settings

ainame/smart-newline.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smart-newline.el

Build Status

The smart-newline.el provide a stress-less newline command for programmer. This extension's usage is VERY SIMPLE. Because, you have to ONLY press RET key.

INSTALL

write in your ~/.emacs.d/init.el

(setq el-get-sources '(
        (:name smart-newline
               :type github
               :website "https://github.com/ainame/smart-newline.el"
               :pkgname "ainame/smart-newline.el")
        )
)

after M-x el-get-list-packages

CONFIGURATION

write in your ~/.emacs.d/init.el

  • by minor-mode

smart-newline command bind to RET and C-m.

(smart-newline-mode 1)

or

(add-hook 'ruby-mode-hook ;; or any major-mode-hooks
  (lambda ()
  (smart-newline-mode 1)))
  • by only using any key-bind
(define-key global-map (kbd "C-j") 'smart-newline) ;; or any key as you like

BEHAVIORS

List up smart-newline behaviors.

In this section, I use following words.

  • newline - Emacs's default command at RET or C-m
  • open-line - Emacs's default command at C-o
  • indent - indent-according-to-mode command and almost Emacs's default command at TAB or C-i

And in these sample figures, | representation editor's cursor.

In this description, display in ruby-mode patterns for example.You can see some patterns in other major-mode in test cases .

pattern 1

def foo|  RET  def foo
end        ->    |
               end

newline and indent when the cursor exists at end of line.

  • default Emacs: C-j / RET -> TAB
  • smart-newline: RET

pattern 2

 def foo   RET  def foo
|end        ->    |
                end

open-line and indent at begininng of line which has chars.

  • default Emacs: C-o -> TAB
  • smart-newline: RET

pattern 3

object = |VeryVeryVeryLongSomeClassName.create_object

 | RET
 V

object =
  |VeryVeryVeryLongSomeClassName.create_object

newline and indent like C-j

  • default Emacs: C-j / RET -> TAB
  • smart-newline: RET

pattern 4

def foo         def foo          def foo
end       RET   end       RET    end
|         --->  |         --->
def bar                          |
end             def bar
                end              def bar
                                 end

You can insert balanced blank line around start point by only RET. At the end, you will write new a method in smooth.

  • default Emacs: RET -> RET -> C-p / RET -> C-o
  • smart-newline: RET -> RET

pattern 5

def foo         def foo
end             end
          RET
|         --->  |
def bar
end             def bar
                end
  • default Emacs: C-o
  • smart-newline: RET

pattern 6

 def foo         def foo        def foo        def foo
 end       RET   end      RET   end      RET   end
|def bar   --->  |        --->  |        --->
 end             def bar                       |
                 end            def bar
                                end            def bar
                                               end
  • default Emacs: C-o -> C-o -> RET
  • smart-newline: RET -> RET -> RET

pattern 7

def foo         def foo        def foo        def foo
end|      RET   end      RET   end      RET   end
def bar   --->  |        --->           --->
end             def bar        |              |
                end            def bar
                               end            def bar
                                              end
  • default Emacs: RET -> RET -> C-o
  • smart-newline: RET -> RET -> RET

About

The smart-newline.el provide a stress-less newline command for programmer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published