Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use VIM for keeping a sort of log book, behaving like VIM help, like in this VIM tip. I have it all set up, except for one little thing: how can I trick :helptags into taking a variable as an argument? I don't want to hard-code the path.

What I want to do is basically this:

let g:NotesFilePath='~/Dropbox/notes'
nmap ,nh :helptags g:NotesFileDir<CR>

Of course, then it says E150: Not a directory: g:NotesFileDir

So the question is: is there a way to trick :helptags into taking a variable argument, or do I have to hard-code the path?

EDIT: I did manage to add the directory to my runtime path, so the tags file is picked up by VIM, so that's not a problem.

Oh, and symlinking isn't really an option for me: I want to save the file in a Dropbox so I can share it between my machines (including one Windows box).

share|improve this question
up vote 1 down vote accepted
nmap ,nh :exe "helptags" . g:NotesFileDir<CR>
share|improve this answer
4  
Although this is a fairly simple example, it's good practice to use fnameescape() when giving a filename to :exe (shellescape() if the :exe is executing a shell command). E.g., this would end up being: nmap ,nh :exe "helptags " . fnameescape(g:NotesFileDir)<CR> – jamessan Nov 2 '09 at 22:37
    
@jamessan Good point, thanks for the tip. – jqno Nov 3 '09 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .