How to insert newline without indent in the same line in YAML mode?

538 Views Asked by At

I have this function attach to enter:

(defun new-line-and-indent-fix ()
  (interactive)
  (newline)
  (indent-for-tab-command))

and in YAML mode it insert indent when I type enter

before enter (| is cursor)

mc_autosave_progress:
  route: /@plac-budowy@/autozapis/{type}/{id}
  target: { controller: MyConstruction, process: autosave }
  requirements: { type: 'progress', id: \d+ }
  suffix: .json

mc_autosave:|

after

mc_autosave_progress:
  route: /@plac-budowy@/autozapis/{type}/{id}
  target: { controller: MyConstruction, process: autosave }
  requirements: { type: 'progress', id: \d+ }
  suffix: .json

  mc_autosave:
    |

I have the same behaviour when I use just newline.

1

There are 1 best solutions below

1
On

Test with emacs -q (just eval your function and yaml-mode.el, then use M-x yaml-mode in one of your YAML files).

If problem is not reproduced, issue is in your init file. If it is reproduced, problem is elsewhere.

It seems that the problem was in my init file. I found it, it was (electric-indent-mode +1)