See the contents of an included file

8 views
Skip to first unread message

russur...@verizon.net

unread,
May 12, 2021, 1:03:35 PM5/12/21
to vim...@googlegroups.com
Hi,

I'm a tech writer and I use Vim for all my writing. Currently we are authoring in Markdown. To save time and keep consistency, I've been using include files for boilerplate text. It is usually of a form:

#include doc/site/pages/include/sample.tmpl

Just having that line in another file, I was wondering if there was a way I could expand the contents, temporarily, so I could read the text in the current flow while still keeping it in its include location? Kind of like folding/unfolding.

Any help is appreciated!

Thanks,

Russ

Stan Brown

unread,
May 12, 2021, 1:52:08 PM5/12/21
to vim...@googlegroups.com

On 2021-05-12 10:03, russurquhart1 via vim_use wrote:
> To save time and keep consistency, I've been
> using include files for boilerplate text. It is usually of a form:
>
> #include doc/site/pages/include/sample.tmpl
>
> Just having that line in another file, I was wondering if there was a
> way I could expand the contents, temporarily, so I could read the text
> in the current flow while still keeping it in its include location? Kind
> of like folding/unfolding.

I have this mapping in my _vimrc, as suggested by the help:
:map gf :sp<cfile><CR>
Then when I type gf Vim splits the window, opens the file in the new
window, and jumps to it. (The cursor can be anywhere on the file name;
see ":h gf" for more.)

You can close the file and window with :q in the usual way.

--
Stan Brown
Tehachapi, CA, USA
https://BrownMath.com
https://OakRoadSystems.com

Tim Chase

unread,
May 12, 2021, 4:28:56 PM5/12/21
to vim...@googlegroups.com
On 2021-05-12 10:51, Stan Brown wrote:
> I have this mapping in my _vimrc, as suggested by the help:
> :map gf :sp<cfile><CR>
> Then when I type gf Vim splits the window, opens the file in the new
> window, and jumps to it. (The cursor can be anywhere on the file
> name; see ":h gf" for more.)

In case you don't already know it, this sounds like the behavior that

ctrl+w f

gives you, so you can keep "gf" around to open the file under the
cursor in the *same* window and use ^Wf to open the file under the
cursor in a *new* window :-)

(that said, I think the OP was asking for a visual inclusion of the
other file which is a lot more challenging to do. I'm of this
open-in-a-new-window school, too)

-tim

:help CTRL-W_f




Reply all
Reply to author
Forward
0 new messages