sponsor Vim development Vim logo Vim Book Ad

intermediate Tip #823: Add your note files to vim's help system.

 tip karma   Rating 55/16, Viewed by 996 

created:   November 17, 2004 18:25      complexity:   intermediate
author:   Staale Flock      as of Vim:   5.7

I guess you have one or more files containing short notes regarding your computer, stuff you study and suche. If you have several years of notes laying around, and are like me..:o), You tend to forget what's in your notes and you start grepping through your files ore start over again to figure stuff out.

One of my solution has been to vim-helpify my note files and add a link to them from my ~/.vim/doc/ folder.

This is the process:
Make a few changes to your note file.

---- sample notes file start -------------------------------
" vim: filetype=help foldmetod=tags foldtags=<<<,>>> modifiable noreadonly
NOTE! You need the noreadonly and modifiable keywords in the vim modeline above. help files are by default regarded as readonly and nomodifiable files by vim.

Notes about sed *sed* *sfsed* <<<
swapping word's in stream (I know, you don't need the cat)
cat Myfile.h|sed 's/foo/fyy/g'


Notes about vim *vim* *sfvim* <<<
Stuff I have learned about vim.
Create a help link like this |add-local-help|
Regenerate help tags: |helptags|

A realy big section closed with a tag <<<
--- lots of stuf ---
Closing tag >>>


Telephonelist *sfphone* <<<
mom: 555-676767-333
dad: 555-767676-222
sis: 555-121212-999

---- sample notes file end ---------------------------------

As you can see from my sample I tend to prepend my keywords with sf so I can get a handy list with <CTRL+d> later.

I have tried to index files placed in an arbitray place. Sadly enough the helptags command does not seem to like this, so my solution has been to make a soft link from the ~/.vim/doc/ folder to my file. You can do this from vim:
:!ln -s ~/.vim/doc/mynotes.txt ~/Documents/mynotesfile.myext
To have vim create the tags
:helptags ~/.vim/doc

Viola, now when I need that important phone numer it's only one :h command away
:h sfp<CTRL-d>


You could also create your own helptags function adding tags containing a more specifig file position. A realy simple function would be.

function! AddMyHelpTags()
exe 'echo -e "sfsed\t ~/Documents/mynotesfile.mytext\t/\*sfsed\*" >> ~/.vim/doc/tags'
exe 'echo -e "sfphone\t ~/Documents/mynotesfile.mytext\t/\*sfphone\*" >> ~/.vim/doc/tags'
exe 'sort ~/.vim/doc/tags > /tmp/foo.vim.tags'
exe 'mv -f /tmp/foo.vim.tags ~/.vim/doc/tags'
endfunction

NOTE! I do not use such a AddMyHelpTags function myself. But I have tested the principle (The sample function it self is not tested, only the commands). This is just a sample to get you going. Remember that you probably would have to run this AddMyHelpTags function each time :helptags has been called, so as-is it is not very convinient..:o(

Happy viming, regards
Staale Flock

 rate this tip  Life Changing Helpful Unfulfilling 

<<add java import statements easily (assume using ctags) | Choose smaller font in vimdiff mode. >>

Additional Notes

Anonymous, November 17, 2004 18:32
hmm, having my head under my arm I managed to get the modeline in the sample wrong.
There foldmethod=tags should be foldmethod=marker and foldtags=<<<,>>> should be foldmaker=<<<,>>>

Sorry about that

Regards
Staale Flock
Anonymous, November 17, 2004 18:34
Not my day today, foldmarker=<<<,>>>

Staale
Anonymous, November 19, 2004 9:49
Great tip! Thank you!!
[email protected], November 21, 2004 23:50
Great idea!
If you are not able to create the symlink in the vim/doc file, you can do the following:

1.  :set helpfile to a file help.txt in a directory of your choice. The file can be empty.
2.  :set runtimepath+=<directory of new helpfile>
3. :helptags <directory of new helpfile>

than the helptags of all *.txt files in the new directory are additional available.

For me, this works with gvim6.3 but not with gvim6.1

[email protected], November 22, 2004 6:17
I second the "Thanks!". Very good tip.
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 [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo