sponsor Vim development Vim logo Vim Book Ad

Relativize : quickly make a full path name relative to an index.html or tags file

 script karma  Rating 108/27, Downloaded by 1089  Comments, bugs, improvements  Vim wiki

created by
Michael Brown
 
script type
utility
 
description
               Project with a tags file example:

               Open a long full path name from some error log

                vi /some/full/path/to/project/current_project/lib/module/file.ext
               ...

               :Relativize tags<cr>

               if you type :pwd you should get

               /some/full/path/to/project/current_project

               assuming a tags file has been created in the current_project
               file in the past.

               So hopefully this means tag jumps will work and relative
               include paths can be accessed via gf.

               This could also be useful for other landmark files on the
               system (eg. index.html, tags, .project,build.xml,README...etc).
               In the above example
               using the actual file.ext as the argument will make the
               working directory the module directory

               The function will prioritise the deepest tags file.

                I have this in my vimrc to give you some ideas
                
                nnoremap ,pp :split<cr>:enew<cr>:r! tail -n 1000 /var/log/php_errorlog<cr>:set buftype=nofile<cr>Gf/
                nnoremap gft gf:Relativize tags<cr>
                nnoremap gfi gf:Relativize index.php<cr>




         Bugs:

               - Will probably not work with MS windows paths in current form.
               It will probably cause an infinite loop you will need to
               Ctrl-C out of.
  
 
install details
add the relativize.vim into the plugins 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
relativize.vim 0.1 2008-04-02 6.0 Michael Brown 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