How to print (printed) with creases in Vim?

I have a very simple to do 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), but suppose I want to print it and only print, for example, the @W part?

First I will search for:

/&W

      

then collapse (Vim Wikia Simple Folding: Tip 282)

:set foldexpr=getline(v:lnum)!~@/
:nnoremap <F8> :set foldmethod=expr<CR><Bar>zM

      

Now I 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 great with the printable part: all lines are displayed ...

How do I go about printing this folded file?

+3


source to share


1 answer


Unfortunately, :hardcopy

does not respect the current view in the window, it prints physical content (and also has other limitations such as ignoring hiding).

Use a different printing medium

The command :TOhtml

comes with Vim and can create an HTML representation of the current window, including folds. Then you can print this HTML file from your browser.

(Temporarily) remove lines instead of folding



You can do this with the command :global

:

:global!/@W/delete _
:hardcopy
:undo

      

Maybe as a custom command:

:command! -nargs=? HardcopyMatching execute 'global!/' . <q-args> . '/delete _' | hardcopy | undo

      

+6


source







All Articles