Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.