1
0
Fork 0
forked from wezm/wezm.net

Add /technical/2015/09/vim-open-file-at-colon-line-number

This commit is contained in:
Wesley Moore 2015-09-20 14:17:26 +10:00
parent 7e61a86d55
commit 5d12c9aced
3 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,19 @@
I regularly encounter paths that have line numbers attached such as,
`./spec/features/cases/edit_spec.rb:112`, or `src/fetcher.rs:543`, and want to
view or edit the file at the given line. For far too long I've been opening the
file in `vim` and then jumping to the relevant line. This week I wrote a shell
(`zsh`) function that does this automatically. It is simply called `v` and is
used in place of `vim` to edit a file. E.g.
<figure>
<img src="/images/2015/vDemo.gif" style="max-width: 490px; max-height: 362px" alt="Animated GIF of v function in action">
<figcaption>Demo</figcaption>
</figure>
## Source
The source of the function is below. It was written for `zsh` but should be
easy to adapt for other shells.
<script src="https://gist.github.com/wezm/f18e3ec540e7b59337fc.js"></script>

View file

@ -0,0 +1,13 @@
---
title: Open Paths With Line Numbers in Vim
extra: A shell function to open path/to/file.txt123 style paths at the specified line
in vim.
kind: article
section: technical
created_at: 2015-09-20 12:58:00.000000000 +10:00
keywords:
- vim
- shell
- zsh
- productivity
short_url: http://j.mp/1YpZeKP

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB