Neovim switch foo.ml / foo.mli edit=

Is there a way, where

  1. when editing foo/bar.ml, we can switch to foo/bar.mli
  2. when editing foo/bar.mli, we can switch to foo/bar.ml
    ?

Basically I want to swap .ml ↔ .mli for the buffer/file I am editing.

You can use the :r expand modifier to remove the extension from the filename and type the one you want:
From the .ml file :e %:r.mil or from .mil :e %:r.ml

2 Likes