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}' |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 3.236.112.101
|