Reputation: 2401
I have a very simple todo list with dates and tags :
141218 Call school &phone @me
141219 Buy groceries &buy @me
141220 Have W order books &buy @W
141220 Think about vacation &vac @me
141221 Have W try Santa Claus outfit &fam @W
141222 Ask a question to S.O. &vim @me
This list is not long (I have much longer files in mind), but suppose I want to print it, and only print, e.g., the @W part ?
First I shall search :
/&W
then fold (Vim Wikia Simple Folding : Tip 282)
:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM
I now have :
+—- 2 lines
141220 Have W order books &buy @W
+—- 1 line
141221 Have W try Santa Claus outfit &fam @W
+—- 1 line
This works fine down to the hardcopy part : all lines are displayed…
How should I proceed to print this folded file ?
Upvotes: 3
Views: 549
Reputation: 172698
Unfortunately, the :hardcopy
doesn't consider the current representation in the window, it prints the physical contents (and also has other limitations, like ignoring concealment).
The :TOhtml
command ships with Vim, and can create a HTML representation of the current window, including folds. You can then print that HTML file from the browser.
You can do so with the :global
command:
:global!/@W/delete _
:hardcopy
:undo
Maybe as a custom command:
:command! -nargs=? HardcopyMatching execute 'global!/' . <q-args> . '/delete _' | hardcopy | undo
Upvotes: 6