Skip to content

Instantly share code, notes, and snippets.

@gevann
Created September 15, 2017 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gevann/775f23b3d1eca2fc711c99ab9118b8f3 to your computer and use it in GitHub Desktop.
Save gevann/775f23b3d1eca2fc711c99ab9118b8f3 to your computer and use it in GitHub Desktop.
python snippet for inserted the relative path for a fzy-found file
python << endpython
import vim
import os
def other_file():
return vim.eval("system(\"rg . --files -g '' | fzy \")")
def relpath():
target = other_file()
relative_path = os.path.relpath(target, vim.current.buffer.name).strip()
vim.command("redraw!")
vim.command("normal! o'%s'"%relative_path)
endpython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment