From 86a9885dbeaf4e9bcc9670e40e4badb309aebaa2 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 31 Aug 2017 14:31:00 -0500 Subject: [PATCH] Add Go To File With Line Number as a vim til --- README.md | 3 ++- vim/go-to-file-with-line-number.md | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 vim/go-to-file-with-line-number.md diff --git a/README.md b/README.md index 17fe005..0c9fe25 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_553 TILs and counting..._ +_554 TILs and counting..._ --- @@ -573,6 +573,7 @@ _553 TILs and counting..._ - [Format Long Lines To Text Width](vim/format-long-lines-to-text-width.md) - [Generate and Edit Rails Migration](vim/generate-and-edit-rails-migration.md) - [Get The pid Of The Session](vim/get-the-pid-of-the-session.md) +- [Go To File With Line Number](vim/go-to-file-with-line-number.md) - [Grepping Through The Vim Help Files](vim/grepping-through-the-vim-help-files.md) - [Head of File Name](vim/head-of-file-name.md) - [Help For Non-Normal Mode Features](vim/help-for-non-normal-mode-features.md) diff --git a/vim/go-to-file-with-line-number.md b/vim/go-to-file-with-line-number.md new file mode 100644 index 0000000..3c45266 --- /dev/null +++ b/vim/go-to-file-with-line-number.md @@ -0,0 +1,23 @@ +# Go To File With Line Number + +I often use `gf` as supported by Vim or with the help of plugins like +[`rails.vim`](https://github.com/tpope/vim-rails) as a way of quickly +navigating to existing files. For unloaded files, this loads a buffer with +the cursor at the top of the buffer. For existing buffers, it opens to that +buffer with the cursor where it was when you left. + +Vim also supports a slightly fancier goto file command, `gF`. If this +command is used while the cursor is over a file with a line number appended +to the end, it will not only open up a buffer with that file, it will move +the cursor to the specified line number. + +With this repository, I could try it out by moving the cursor over the +following text and hitting `gF`. + +```text +README.md:100 +``` + +This will open up a buffer for `README.md` with the cursor at line 100. + +See `:h gF` for more details.