Reputation: 815
I use elpy and yasnippet to make emacs become a python editor.
Then I use yasnipprt to build a class object, but I find I can't exit field as quickly as sublime text can, within double "return". That means I have to move cursor at the begin of line used tab or keyboard one by one at the end of class object, and type new code in, then I can exit class field which yasnippet supported.
Have anyone had same confusion about exit field?
I push init.el code below, and what is the key that exit field of yasnippet?
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
;;;(add-to-list 'package-archives
;;; '("elpy" . "http://jorgenschaefer.github.io/packages/"))
(package-initialize)
(elpy-enable)
(add-to-list 'load-path
"~/.emacs.d/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
(c-add-style
"python-new"
'((indent-tabs-mode . 4)
(fill-column . 78)
(c-basic-offset . 4)
(c-offsets-alist . ((substatement-open . 0)
(inextern-lang . 0)
(arglist-intro . +)
(knr-argdecl-intro . +)))
(c-hanging-braces-alist . ((brace-list-open)
(brace-list-intro)
(brace-list-close)
(brace-entry-open)
(substatement-open after)
(block-close . c-snug-do-while)))
(c-block-comment-prefix . "* "))
)
;; This is a very crude hook that auto-selects the C style depending on
;; whether it finds a line starting with tab in the first 3000 characters
;; in the file
(defun c-select-style ()
(save-excursion
(if (re-search-forward "^\t" 3000 t)
(c-set-style "python")
(c-set-style "python-new"))))
(add-hook 'c-mode-hook 'c-select-style)
Upvotes: 0
Views: 534
Reputation: 137096
I think you're asking how to jump between fields in yasnippet.
TAB
(yas-next-field-or-maybe-expand
)S-TAB
(yas-prev-field
)C-d
(yas-skip-and-clear-or-delete-next-char
)Upvotes: 4