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.
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
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
List up smart-newline behaviors.
In this section, I use following words.
- newline - Emacs's default command at
RET
orC-m
- open-line - Emacs's default command at
C-o
- indent -
indent-according-to-mode
command and almost Emacs's default command atTAB
orC-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 .
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
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
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
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
def foo def foo
end end
RET
| ---> |
def bar
end def bar
end
- default Emacs:
C-o
- smart-newline:
RET
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
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