Anonymous View
    sponsor Vim development Vim logo Vim Book Ad

CreateMenuPath.vim : Create a menu that mirrors a directory tree

 script karma  Rating 24/17, Downloaded by 4550  Comments, bugs, improvements  Vim wiki

created by
Christian J. Robinson
 
script type
utility
 
description
This file provides a function to create a menu that mirrors a directory tree.

Usage:
CreateMenuPath({path} [, {configuration dictionary options}])

Examples:
:call CreateMenuPath('~')   " Creates a menu of your home directory.

:call CreateMenuPath('~/public_html', {'menu': 'Files.Web Page', 'priority': '600.100', 'ignore_pats': ['\c.\(gif\|jpe\=g\|png\|ico\|bmp\|tiff\=\)$'], 'recurse_limit': 10)  " "Files.Web Page" menu, priority 600.100, ignoring some image files, maximum depth of 10 subdirectories.

A default filename ignore pattern is provided which ignores a number of image, audio and archive files, but it's incomplete.

The global variable "CMP_Recurse_Limit" can be set to specify the maximum sub-directory depth to scan.  Set it to 0 for infinite recursion (bad idea, likely to fail).  Set it to 1 to scan only the specified directory.
 
install details
Either :source it or put it in your plugin directory.
 

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
CreateMenuPath.vim 4.1 2026-05-21 9.1 Christian J. Robinson - Corrections and fixes
- A known bug exists where a lot of recursion starts causing errors
CreateMenuPath.vim 4.0 2026-05-21 9.1 Christian J. Robinson - Somehow the script has been broken for a long time
- Breaking change: Change function arguments syntax
CreateMenuPath.vim 3.0 2022-08-22 9.0 Christian J. Robinson - Update for Vim 9 (no new features)
CreateMenuPath.vim 2.0 2008-05-23 7.0 Christian J. Robinson Update for Vim7:
  - Allow more than one ignore pattern argument
  - Looping over the found files is simpler
CreateMenuPath.vim 1.5 2002-03-15 6.0 Christian J. Robinson - Don't add a / or \ before the glob pattern if it's already there. (Fixes that a path of 'c:' wouldn't work.)
CreateMenuPath.vim 1.4 2002-01-24 6.0 Christian J. Robinson CMP_Recurse_Limit global variable added.
CreateMenuPath.vim 1.3 2002-01-18 6.0 Christian J. Robinson - Use a dummy menu item to prevent a torn off menu from disappearing. (Does not work in the PopUp menu.)
CreateMenuPath.vim 1.2 2002-01-10 6.0 Christian J. Robinson - Rescan menu item didn't work.
- Escape some characters in CD Here menu item.
- Create a ...More menu when the number of menu items exceeds 30, and add shortcut keys.
CreateMenuPath.vim 1.1 2002-01-10 6.0 Christian J. Robinson - Two menu items added:  "CD Here" and "Rescan"
- Clear the menu out before building it.  (Marcin Juszkiewicz)
ip used for rating: 3.136.142.2

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github