sponsor Vim development Vim logo Vim Book Ad

html_FileCompletion : Base dir- and URL-aware file completion for HTML links.

 script karma  Rating 7/4, Downloaded by 2299  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
ftplugin
 
description
DESCRIPTION
This plugin offers insert mode file completion for HTML links to local files,
taking into account a base directory (document root) and base URL (web server
location) to enable completion of absolute (/foo...) and fully qualified
(http://host/foo...) links.

RELATED WORKS
- FilePathConvert.vim (vimscript #4885) converts filespecs between absolute,
  relative, and URL (file://) formats.

USAGE
CTRL-X CTRL-F           Find matches for file names that start with the same
                        'isfname' characters as before the cursor. File names
                        are inserted in URL-escaped form (e.g. <Space> -> %20)
                        and always with forward slashes as path separator.
                        An absolute file path starting with "/" is interpreted
                        relative to b:basedir, and a base URL b:baseurl is
                        stripped off the front. This enables you to complete
                        file links even though they are specified as absolute
                        or fully qualified links in the HTML.
                        When there are no matches within the base directory,
                        this falls back to default, non-URL-escaped file
                        completion (i_CTRL-X_CTRL-F).
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim html_FileCompletion*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.019 or
  higher.

CONFIGURATION
Set the following variables in autocmds, filetype plugins or a local vimrc:
                                                                   b:basedir
Specifies the local directory that represents the document root of the edited
HTML file, i.e. where an absolute link starting with "/" points to. To make
this resistant to changes in the CWD, this should be an absolute dirspec. In a
local vimrc located at the document root, you could use:
    let b:basedir = expand('<sfile>:p:h')
                                                                  b:baseurl
Specifies the server location of the b:basedir document root; i.e. a fully
qualified link to the document root, including protocol and hostname.

For a permanent configuration, put the following commands into your vimrc:

The b:basedir can be auto-discovered when it isn't set. Starting with the
directory the current file is in, it will traverse the directory hierarchy
upward until it finds a directory that does _not_ contain typical HTML files,
and will then take the previous directory as the document root. You can adapt
the file glob of what represents files within the document root via:
    let g:html_FileCompletion_WithinDocRootGlob = '*.{htm,html,xhtml,asp,gsp,jsp,php}'
 

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
html_FileCompletion-1.20.vmb.gz 1.20 2014-05-31 7.0 Ingo Karkat - Detect absolute filespecs and handle them like the build-in file completion, as the default mapping overrides that. If the user wants to convert the filespec into a link, she must do this explicitly via the html_PathConvert.vim plugin.
- Add dependency to ingo-library (vimscript #4433). *** You need to separately install ingo-library (vimscript #4433) version 1.019 (or higher)! ***
html_FileCompletion-1.12.vmb.gz 1.12 2014-05-21 7.0 Ingo Karkat FIX: Include autoload scripts in Vimball that are missing in version 1.11.
html_FileCompletion.vba.gz 1.11 2012-06-15 7.0 Ingo Karkat FIX: Do not clobber the global CWD when the buffer has a local CWD set.
html_FileCompletion.vba.gz 1.10 2012-05-21 7.0 Ingo Karkat ENH: Auto-discover b:basedir by traversing up the directories until one is found that contains no HTML files.
html_FileCompletion.vba.gz 1.00 2012-05-15 7.0 Ingo Karkat Initial upload
ip used for rating: 3.236.112.101

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