Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

apathy.vim: Set the 'path' option for miscellaneous file types

NotificationsYou must be signed in to change notification settings

tpope/vim-apathy

Repository files navigation

Apathy sets the five path searching options —'path','suffixesadd','include','includeexpr', and'define' — for file types I don't careabout enough to bother with creating a proper plugin.

Rationale

As you might have guessed from/usr/include being in the default, theoriginal purpose of the'path' option was to house the C preprocessorinclude path. This enabled Vim to parse a preprocessor declaration like#include <stdio.h> and determine that the file being included was/usr/include/stdio.h. Several features are built-in on this groundwork:

  • gf,<C-W>f,<C-W>gf: jump to the included file under the cursor.
  • :find,:sfind,:tabfind: jump to the specified included file.
  • [i: display the first line in the current file or an included filecontaining the keyword under the cursor.
  • ]i: like above, but start searching after the cursor.
  • :isearch: like above, but give your own line range and search pattern.
  • [I,]I,:ilist: like above, but display all matches.
  • [<C-I>,]<C-I>,<C-W>i,:ijump,:isplit: like above, but jump tothe match.
  • <C-X><C-I>: complete keywords from included files.
  • [d,]d,:dsearch,[D,]D,:dlist,[<C-D>,]<C-D>,<C-W>d,:djump,:dsplit,<C-X><C-D>: like theiri equivalents, but for macrodefinitions.
  • :checkpath: list missing included files.

I list these exhaustively to stress that included files aren't just apotential use of'path', they are the very purpose of'path'. If you'vebeen using'path' to contain a list of commonly accessed directories orsomething like**/*, you're precluding yourself from using 38 differentcommands. Oops! (Try one of the many fuzzy finder plugins instead.)

While Vim is set up for C by default, it provides a few options to use thesefeatures for other languages:

  • 'include' is a pattern for matching include declarations, defaulting to^\s*#\s*include. A value for JavaScript imports might look like\<require\|\<from.
  • 'includeexpr' is a simple function for converting an include to afilename. In languages like Java, Lua, and Python, this could be used tochangefoo.bar intofoo/bar.
  • 'suffixesadd' is a list of file extensions to try. JavaScript might usesomething like.js,.coffee.
  • 'define' is a pattern for matching macro definitions, defaulting to^\s*#\s*define. This doesn't serve much purpose for languages without apreprocessor, but sometimes it is helpful to make it match function and/orvariable declarations.

These, along with'path', make up the purview of Apathy.

Supported file types

Additionally, the C related defaults are stripped out of the global config, soyou don't have to worry about/usr/include tainting everything.

Related plugins

Installation

Install using your favorite package manager, or use Vim's built-in packagesupport:

mkdir -p ~/.vim/pack/tpope/startcd ~/.vim/pack/tpope/startgit clone https://tpope.io/vim/apathy.git

License

Copyright © Tim Pope. Distributed under the same terms as Vim itself.See:help license.

About

apathy.vim: Set the 'path' option for miscellaneous file types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp