is there any Emacs lisp add-on that allows me to edit or enter data in yaml file easily.
For example:
--- sample yaml file --- Name : Addr : City : State: Zip : Phone: Email --- End ----
When the file is opened in Emacs, the cursor will be automatically placed at the first Yaml key. In this case "Name:", when I finish entering a name after the "Name:" and hit return, it will automatically move to the next key. in this case "Addr:"
forward / backward tab can be used to move back and forth between keys.
Is there anything out there for this?
Thanks!
http://emacswiki.org/emacs/YamlMode
I gather bits and pieces from the net and got this:
(defun yaml-next-field ()
"Jump to next yaml field"
(interactive)
(search-forward-regexp ": *"))
(defun yaml-prev-field ()
"Jump to next yaml field"
(interactive)
(search-backward-regexp ": *"))
(add-hook 'yaml-mode-hook
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)
(define-key yaml-mode-map "\M-\r" 'insert-ts)
(define-key yaml-mode-map (kbd "C-<tab>") 'yaml-next-field)
(define-key yaml-mode-map (kbd "C-S-<tab>") 'yaml-prev-field)
))
You can define a custom macro that does what you want.
It could something like this:
;; define named macro
(fset 'jump-next-colon
[?\C-f ?\C-s ?: ?\C- ? ])
;; assign shortcut ctrl+alt+j
(global-set-key (kbd "C-M-j") 'jump-next-colon)
If this is not exactly what you are looking for you can write your own macro. See http://emacswiki.org/emacs/KeyboardMacros
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With