Add :Read ex command & 'SPC i p' keybind

This can be used to extract paths from evil-ex style paths. e.g. the
following inserts the stdout into the current buffer (assuming we're in
~/some/project/filename.c):

  :R!echo %:P      ~/some/project
  :R!echo %:t      filename.c
  :R!echo %:e      c
  :R!echo %:r      filename
  :R!echo ~/another/project/%:t:r.h
    ~/another/project/filename.h
  :R %             contents of current file

http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers
has a full list of vim filename modifiers. Doom doesn't support all of
them, but it does support most of them.
This commit is contained in:
Henrik Lissner 2019-11-15 14:26:09 -05:00
parent ad2b905330
commit 46bea60ad3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 10 additions and 2 deletions

View file

@ -182,3 +182,9 @@ non-nil, a search is preformed against Doom's manual (wiht `doom/help-search')."
(evil-ex-completed-binding (match-string 1 query))))
((message "Searching for %S, this may take a while..." query)
(apropos query t))))))
;;;###autoload (autoload '+evil:read "editor/evil/autoload/ex" nil t)
(evil-define-command +evil:read (count file)
"Alternative version of `evil-read' that replaces filename modifiers in FILE."
(interactive "P<fsh>")
(evil-read count (evil-ex-replace-special-filenames file)))