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
<<add java import statements easily (assume using ctags) |
Choose smaller font in vimdiff mode. >>
Additional Notes
|