mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
move index.org subsection into snippet-expansion.org
This commit is contained in:
parent
fd8423cb63
commit
7b82424735
@ -127,42 +127,6 @@
|
|||||||
If you run into problems using YASnippet, or have snippets to contribute,
|
If you run into problems using YASnippet, or have snippets to contribute,
|
||||||
post to the [[http://groups.google.com/group/smart-snippet][yasnippet forum]]. Thank you very much for using YASnippet!
|
post to the [[http://groups.google.com/group/smart-snippet][yasnippet forum]]. Thank you very much for using YASnippet!
|
||||||
|
|
||||||
|
|
||||||
* Expanding Snippets
|
|
||||||
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: expand-snippets
|
|
||||||
:END:
|
|
||||||
|
|
||||||
This section describes how YASnippet chooses snippets for expansion at point.
|
|
||||||
|
|
||||||
Maybe, you'll want some snippets to be expanded in a particular
|
|
||||||
mode, or only under certain conditions, or be prompted using
|
|
||||||
|
|
||||||
** Triggering expansion
|
|
||||||
|
|
||||||
To make a snippet expand after the cursor:
|
|
||||||
|
|
||||||
* Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]]. It's bound to
|
|
||||||
=TAB= and =<tab>= by default, to change it use
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp :exports code
|
|
||||||
(define-key yas-minor-mode-map (kbd "<tab>") nil)
|
|
||||||
(define-key yas-minor-mode-map (kbd "TAB") nil)
|
|
||||||
(define-key yas-minor-mode-map (kbd "<the new key>") 'yas-expand)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Use the snippet's *keybinding*.
|
|
||||||
|
|
||||||
* Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x
|
|
||||||
yas-insert-snippet== or its keybinding =C-c & C-s=).
|
|
||||||
|
|
||||||
* By expanding directly from the "YASnippet" menu in the menu-bar
|
|
||||||
|
|
||||||
* Using hippie-expand
|
|
||||||
|
|
||||||
* Use m2m's excellent auto-complete
|
|
||||||
|
|
||||||
# Local Variables:
|
# Local Variables:
|
||||||
# mode: org
|
# mode: org
|
||||||
# fill-column: 80
|
# fill-column: 80
|
||||||
|
@ -1,38 +1,49 @@
|
|||||||
|
#+SETUPFILE: org-setup.inc
|
||||||
|
|
||||||
* Expanding snippets
|
* Expanding snippets
|
||||||
|
|
||||||
|
This section describes how YASnippet chooses snippets for expansion at point.
|
||||||
|
|
||||||
|
Maybe, you'll want some snippets to be expanded in a particular
|
||||||
|
mode, or only under certain conditions, or be prompted using
|
||||||
|
|
||||||
** Triggering expansion
|
** Triggering expansion
|
||||||
|
|
||||||
You can use YASnippet to expand snippets in different ways:
|
You can use YASnippet to expand snippets in different ways:
|
||||||
|
|
||||||
- By typing an abbrev, the snippet /trigger key/, and then pressing the
|
- When =yas-minor-mode= is active:
|
||||||
key defined in =yas-trigger-key= (which defaults to "TAB"). This
|
- Type the snippet's *trigger key* then calling [[sym:yas-expand][=yas-expand=]]
|
||||||
works in buffers where the minor mode =yas-minor-mode= is active;
|
(bound to =TAB= by default).
|
||||||
|
|
||||||
- By invoking the command =yas-insert-snippet= (either by typing
|
- Use the snippet's *keybinding*.
|
||||||
=M-x yas-insert-snippet= or its keybinding). This does /not/ require
|
|
||||||
=yas-minor-mode= to be active.
|
|
||||||
|
|
||||||
- By using the keybinding associated with an active snippet. This also
|
|
||||||
requires =yas-minor-mode= to be active;
|
|
||||||
|
|
||||||
- By expanding directly from the "YASnippet" menu in the menu-bar
|
- By expanding directly from the "YASnippet" menu in the menu-bar
|
||||||
|
|
||||||
- By using hippie-expand
|
- Using hippie-expand
|
||||||
|
|
||||||
|
- Call [[sym:yas-insert-snippet][=yas-insert-snippet=]] (use =M-x yas-insert-snippet== or its
|
||||||
|
keybinding =C-c & C-s=).
|
||||||
|
|
||||||
|
- Use m2m's excellent auto-complete
|
||||||
|
TODO: example for this
|
||||||
|
|
||||||
- Expanding from emacs-lisp code
|
- Expanding from emacs-lisp code
|
||||||
|
|
||||||
*** Trigger key
|
*** Trigger key
|
||||||
|
|
||||||
When =yas-minor-mode= is enabled, the keybinding taken from
|
=yas-expand= tries to expand a /snippet abbrev/ (also known as
|
||||||
=yas-trigger-key= will take effect.
|
/snippet key/) before point.
|
||||||
|
|
||||||
=yas-trigger-key= invokes =yas-expand=, which tries to expand a /snippet
|
When =yas-minor-mode= is enabled, it binds [[sym:yas-expand][=yas-expand=]] to =TAB= and
|
||||||
abbrev/ (also known as /snippet key/) before point.
|
=<tab>= by default, however, you can freely set it to some other key:
|
||||||
|
|
||||||
The default key is ="TAB"=, however, you can freely set it to some other
|
#+begin_src emacs-lisp :exports code
|
||||||
key.
|
(define-key yas-minor-mode-map (kbd "<tab>") nil)
|
||||||
|
(define-key yas-minor-mode-map (kbd "TAB") nil)
|
||||||
|
(define-key yas-minor-mode-map (kbd "<the new key>") 'yas-expand)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
[[images/minor-mode-indicator.png]]
|
[[./images/minor-mode-indicator.png]]
|
||||||
|
|
||||||
To enable the YASnippet minor mode in all buffers globally use the
|
To enable the YASnippet minor mode in all buffers globally use the
|
||||||
command =yas-global-mode=.
|
command =yas-global-mode=.
|
||||||
@ -41,9 +52,6 @@ When you use =yas-global-mode= you can also selectively disable
|
|||||||
YASnippet in some buffers by setting the buffer-local variable
|
YASnippet in some buffers by setting the buffer-local variable
|
||||||
=yas-dont-active= in the buffer's mode hook.
|
=yas-dont-active= in the buffer's mode hook.
|
||||||
|
|
||||||
Trouble when using or understanding the =yas-trigger-key= is easily the
|
|
||||||
most controversial issue in YASsnippet. See the [[faq.html][FAQ]].
|
|
||||||
|
|
||||||
**** Fallback bahaviour
|
**** Fallback bahaviour
|
||||||
|
|
||||||
=yas-fallback-behaviour= is a customization variable bound to
|
=yas-fallback-behaviour= is a customization variable bound to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user