edit

open a file with :<line_num> syntax in vim, emacs, or vscode

Vim and Emacs, and who knows what else, don’t handle the path/to/file.txt:<line_number> syntax that’s output by so many things.

This lets you edit a file at the appropriate line in vim, emacs, and vscode by just copying that output from your logs, or whatever, and pasting it in after edit. Yes you could edit the output and do it manually but that gets old (annoying) fast.

So, edit path/to/foo:44 will open up the foo file at line 44.

Note: no, you don’t need this for vscode. The code command works just fine without it, but I added it for some handwavey sense of “completeness”. :P

Usage

USAGE: edit <path ending with :<num>>
       Please specify a file to edit.
       example:
       edit foo/bar/baz.rb:44

       Set your EDITOR env variable to emacs, code, or any *vim variant.

       I'll open the provided file to the specified line number

Metadata:

Tags:

  • emacs
  • vim
  • vscode