Editing Emacs Yaml

is there any addition of Emacs lisp that allows me to easily edit or enter data into a yaml file.

For example:

  --- sample yaml file ---
 Name: 
 Addr:
 City:
 State:
 Zip:

 Phone:
 Email
 --- End ----

When a file is opened in Emacs, the cursor will automatically be placed in the first Yaml key. In this case, “Name:”, when I finish entering the name after “Name:” and press “Return”, it will automatically move to the next key. in this case "Addr:"

the forward / back tab can be used to move between the keys.

Is there anything for this?

Thanks!

+7
source share
4 answers
+5
source

I collect the pieces from the net and get the following:

(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 "\Cm" '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 "CS-<tab>") 'yaml-prev-field) )) 
+3
source

You can define a custom macro that does what you want.

It could be something like this:

 ;; define named macro (fset 'jump-next-colon [?\Cf ?\Cs ?: ?\C- ? ]) ;; assign shortcut ctrl+alt+j (global-set-key (kbd "CMj") '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

+1
source

jump-char can help. It allows you to quickly jump to the next / previous appearance of the character.

0
source