> I have a file -- my journal -- in which I've been trying to figure out how manual folding works, and how to get it to work for me in a way that's reasonably close to what I want to accomplish.
>
> What it would like to do would be to collapse each daily entry to a single line showing only the date and the day, which is the first line of the entry, and then to be able to reopen the file with the folds displayed as saved. With the following commands in my .vimrc I've been able to accomplish the latter
>
> autocmd BufWinLeave *.txt mkview
> autocmd BufWinEnter *.txt silent loadview
Manual folding is the wrong tool, you are going to create more
problems than you solve. What you need is a file format that supports
an outline structure and thus can be folded by Vim automatically.
My favorite markup is fold markers with levels, which was already
suggested by others. This is one of Vim's built-in folding methods
:set fdm=marker
:help fold-marker
Example file
-------------------------------------------
2011 {{{1
2011-06 {{{2
2011-06-16 Thu {{{3
blah blah
2011-06-17 Fri {{{3
blah blah
{{{ yap yap
yap yap yap
yap yap }}}
2011-07 {{{2
Vim modelines {{{1
vim: fdm=marker fmr={{{,}}}
-------------------------------------------
Note that you don't have to include end fold markers with levels: }}}
1, }}}2, etc. They are not needed and are too easy to mess up in a
large and complex file. Matching fold markers without levels
{{{ and }}} are handy for folding occasional smaller regions. The
drawback of this format is that it is difficult to change outline
structure--level numbers need to be changed. I wrote VOoM plugin for
that. It can also handle other outline formats:
http://www.vim.org/scripts/script.php?script_id=2657
There are various Vim plugins on vim.org for outlining and note-
taking. Each relies on its own markup format. They usually have
folding set up out of the box. Some of the well known:
VimOutliner: http://www.vim.org/scripts/script.php?script_id=3515
The Vim Outliner: http://vim.sourceforge.net/scripts/script.php?script_id=517
Viki: http://www.vim.org/scripts/script.php?script_id=861
Vimwiki: http://www.vim.org/scripts/script.php?script_id=2226
You can also try one the popular light-weight markup languages:
Markdown, txt2tags, reST. In theory, they all can have folding set up
on headlines. I posted foldexpr for Markdown here:
http://groups.google.com/group/vim_use/browse_thread/thread/9beeb7abaad23cb3/
The Emacs Orgmode is probably the most powerful as a journaling tool,
but Vim plugins for it are work in progress.
Regards,
Vlad
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment