sponsor Vim development Vim logo Vim Book Ad

lookupfile : Lookup files using Vim7 ins-completion

 script karma  Rating 782/219, Downloaded by 20316  Comments, bugs, improvements  Vim wiki

created by
Hari Krishna Dara
 
script type
utility
 
description
Now requires Vim 7.1 version.

Lookupfile is a very simple approach to opening files by typing a pattern to
represent the file you are looking for, and selecting a file from the completion
dropdown to open in the current Vim session. It provides a consistent interface
to lookup files by various means (tags, path, buffers, external tools etc.). It
uses the new Vim7 insert-mode completion mechanism to show matching files.

The most part of the plugin is autoloaded so it doesn't increase the startup time and doesn't take up Vim resources until it is used for the first time.

Here are the list of commands that the plugin defines:
        LookupFile      Lookup files from tag files. This is a like a fast GNU
                        find on name. It can lookup files from any Vim
                        compatible tag file (which includes those from ctags),
                        but at the moment it is advisable to generate
                        specialized tag files using :find command (see
                        |lookupfile-tags|).
        LUPath          Lookup files from 'path' using |globpath()|. The :find
                        command while being able to lookup files from 'path', it
                        doesn't provide any completion mechanism, and it is
                        clumsy when there are multiple files with the same name.
                        The :find command doesn't even accept a pattern.
        LUBufs          Lookup loaded files (buffers) using |bufname()|. This is
                        a great addition to whatever buffer-explorer you are
                        using. When there are too many buffers open, this
                        sometimes makes it easy to find the right buffer, by
                        typing part of its name.
        LUWalk          Lookup files using |glob()|. This works like the Emacs
                        ido.el, allowing you to walk up and down a path looking
                        for files. If you use the filename completion with :edit
                        command, then you will find this a lot more convenient
                        and faster to use.
        LUArgs          Lookup files from |:args| list.

It is also very easy to add new commands to or customize the plugin at various
levels. At the simplest, you can create custom command on top of the above that
either pass dynamic arguments or tmporarily change the settings (e.g., you could
have a command that will start LUPath with the 'path' temporarily changed to
find only the include header files). You can also take advantage of the the
|lookupfile-extend| features to add new commands that lookup files from a
completely new source. You can even add commands that lookup something
completely different than a file (like e.g., a spelling using spellsuggest()).

For more information install the plugin and type :h lookupfile after running :heptags command.

Here is what users have to say about the plugin:
    - I am thoroughly enjoying your lookupfile script -- it's just awesome! -- Reva Revadigar (regarding :LookupFile and :LUWalk commands)
    - I use Lookupfile a couple of hundred times a day -- Max Dyckhoff (regarding :LookupFile command)
    - I tried the new plugin. Excellent! Exactly what I want. -- Eddy Zhao (regarding :LUWalk command)



Search_Key_Words: lookupfile util utils lookup complete completion filename open edit file tags path ctags glob globpath Hari Krishna Dara
 
install details
Expand the zip in your runtime directory.
Generate help tags using :helptags command.
Install the latest version of genutils (vimscript #197).
Read help on |lookupfile-installation|.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
lookupfile-1.8.zip 1.8 2007-09-13 7.0 Hari Krishna Dara - Even more control on the mappings with the new setting
  |LookupFile_EnableRemapCmd|.
- New feature to specify names that follow CamelCasing pattern by abbreviating
  them. This works more or less like for the "Open Type" dialog in Eclipse.
  For more information see, |LookupFile_TagsExpandCamelCase|.
- New feature to remember the recent files, see
  |Lookupfile_RecentFileListSize|.
- Changed the message line such that the message is shown on the left side and
  the pattern is shown on the right side. This prevents the more important
  message from getting lost when the filenames are too long.
- New settings |LookupFile_EnableRemapCmd|, |LookupFile_SearchForBufsInTabs|,
  |LookupFile_TagsExpandCamelCase|, |Lookupfile_RecentFileListSize|.
lookupfile-1.7.zip 1.7 2007-05-29 7.0 Hari Krishna Dara - Bug fix: LUPath and LUArgs were broken (stoning at gmail dot com).
- Removed debugging code.
lookupfile-1.6.zip 1.6 2007-05-28 7.0 Hari Krishna Dara Requires Vim 7.1.

This is a combined 1.5(previously unreleased)/1.6 release of lookupfile and includes the following improvements and bugfixes.
- LookupFile now uses CursorHoldI instead of CursorMovedI to show matches. This
  means, the matches are not computed until you stop typing, which should give a
  better experience. See |LookupFile_UpdateTime| for more information.
- The plugin now sets 'completefunc' such that you can now hit <C-X><C-U> to
  trigger completions explicitly (instead of waiting for
  g:LookupFile_UpdateTime). This is useful if you are a slow typer and so prefer
  a large value for g:LookupFile_UpdateTime.
- The plugin now recognizes 'ignorecase' and 'smartcase' settings to match files
  even on systems that are case-sensitive. This is mainly significant for the
  commands that use |globpath()| or |glob()| which are, |:LUPath| and |:LUWalk|,
  as the others already respect these settings.
- There is now a separate command called :LUTags that always does what
  :LookupFile used to do, while the :LookupFile command itself now gets
  dynamically assigned to the last command used. This also means, the map that
  is choosen in |lookupfile-map| now invokes the last command that is used, use
  |LookupFile_DefaultCmd| and |LookupFile_DisableDefaultMap| settings to control
  this behavior.
- LUWalk now supports showing only directory names in the results. Just type
  an extra / to filter those that are not directories (the suffix will then be
  two slashes).
- The default behavior of |:LUBufs| is now to match the entire |bufname()|,
  just like the |:buffer| command would do. To see the old behavior, reset
  |LookupFile_Bufs_LikeBufCmd| setting.
- If you have the new version of SelectBuf also installed, you can have
  |:LUBufs| sort buffers in MRU order. See, |LookupFile_Bufs_BufListExpr|.
- When tags file is not generated as per the requirements of |lookupfile-tags|,
  the format of the matches doesn't look good, so by default the matches just
  show full filenames. See |LookupFile_UsingSpecializedTags| to get better
  formatted results.
- New settings |LookupFile_UsingSpecializedTags|, |LookupFile_SortMethod|,
  |LookupFile_DefaultCmd|, |LookupFile_DisableDefaultMap|,
  |LookupFile_Bufs_LikeBufCmd|, |LookupFile_Bufs_BufListExpr|,
  |LookupFile_EscCancelsPopup|.
- Bug fix: exact matches were getting dropped from results  (Max Dyckhoff).
- Bug fix: <BS> in |:LUWalk| right after selecting a directory match caused it
  to misbehave.
- Bug fix: if tags file is not in the current directory, the opening fails. Now
  :LookupFile expands the filenames explicitly so that the paths are always
  valid.
- Bug fix: Unsetting |LookupFile_AllowNewFiles| didn't disable the feature.
- Bug fix: <C-E> was not hiding the popup.
- Bug fix: <S-BS> triggers the default insert-mode completion (Max Dyckhoff).
- Fixed misc. bugs in opening files.
- Workaround for <Esc> not working on some systems, allow disabling the
  mapping.
- Bug fix: When there is an exising swapfile, opening the files result in an
  error message (David Fishburn).
- When LookupFile_UsingSpecializedTags is set, sorting should be done on the
  filename (patch by Timothy, Guo).
lookupfile-1.4.zip 1.4 2006-08-31 7.0 Hari Krishna Dara - Fixed a bug in the initial pattern getting ignored.
- LUBufs now completes the full pathname of the buffers, so that it is
  less dependent on the current directory of Vim.
- LUBufs and LUPath commands now present the matches in a better format.
- Pressing <F5> while popup is visible didn't close the lookupfile
  window.
lookupfile-1.3.zip 1.3 2006-08-20 7.0 Hari Krishna Dara - New feature to create a file, if the file doesn't already exist (Ido).
  Can be disabled using g:LookupFile_AllowNewFiles setting.
- Bug fix: while using LUWalk, if the first match is a directory, then
  selecting files was offset by one.
lookupfile-1.2.zip 1.2 2006-08-16 7.0 Hari Krishna Dara - New LUWalk command that works very similar to Emacs ido.el to quickly navigate
  paths.
- g:LookupFile_AlwaysAcceptFirst setting to always accept the first
  entry (the default is 0).
- g:LookupFile_FileFilter to specify a filter.
- All commands now accepts the initial pattern as argument. This provides
  unlimited number of possibilities to create your own custom commands (see
  |lookupfile-tips| for some examples).
- The g:LookupFile_MinPatLength is automatically set to 0 except for tag and
  'path' lookup.
- When Lookup window is opened, the filetype is set to "lookupfile". This allows
  you to create ftplugins to fine tune the behavior.
- Renamed :LUBuf command to :LUBufs.
The plugin has been in extensive use by myself and a couple of other users, and there are no major issues.
lookupfile-1.1.zip 1.1 2006-07-05 6.0 Hari Krishna Dara - Added LUBuf, LUPath and LUArgs commands.
- Renamed the prefix for all the settings from g:lookupfile_ to
  g:LookupFile_. This is required to support Funcref settings.
- Now the cursor position is preserved, while opening a file that is
  already loaded.
- Using genutils 2.1.
lookupfile-1.0.zip 1.0 2006-06-23 7.0 Hari Krishna Dara Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github