What would you reccommend as makeprg for compiling nroff documents (for man pages)? I currently have it set to mandoc because it works when I do it from the terminal: mandoc foo.1

When I run :make, it escapes to the terminal and the output stream produced appears to be fine. However the content loaded into the quickfix window is messed up and has weird characters:

||        sstt [--aaiivv] [--cc _c_l_a_s_s] [--ff _f_o_n_t] [--gg _g_e_o_m_e_t_r_y] [--nn _n_a_m_e] [--oo _i_o_f_i_l_e] [--TT
||        _t_i_t_l_e] [--tt _t_i_t_l_e] [--ll _l_i_n_e] [--ww _w_i_n_d_o_w_i_d] [[--ee] _c_o_m_m_a_n_d [_a_r_g_u_m_e_n_t_s...]]
||        sstt [--aaiivv] [--cc _c_l_a_s_s] [--ff _f_o_n_t] [--gg _g_e_o_m_e_t_r_y] [--nn _n_a_m_e] [--oo _i_o_f_i_l_e] [--TT
||        _t_i_t_l_e] [--tt _t_i_t_l_e] [--ww _w_i_n_d_o_w_i_d] -l _l_i_n_e [_s_t_t_y___a_r_g_s...]
||        sstt is a simple terminal emulator.

I tried using the -K (encoding flag) with the available options like utf-8, etc. But it does not seem to work. Any thoughts? It would be really nice to load the compiled man page in a separate split like you can load man pages using the ftplugin/man.vim script and invoking :Man ... (with all the nice syntax highlighting)

On a related note, the quickfix window does not open automatically and I have the following autocommand set (works in all other cases)

autocmd QuickFixCmdPost [^l]* cwindow
  • 2
    I don’t know what mandoc outputs, but if it’s terminal escape sequences, you’re kind of out of luck. I suspect just man will work, but you need an appropriate errorformat! For the separate window, maybe new | read !mandoc # | set filetype=man?
    – D. Ben Knoble
    Dec 8 '20 at 4:17

If anyone is interested, I found a post that addresses this issue: the suggested approach is to pipe the mandoc (or groff) output through col -bx to remove all terminal control characters, like so:

mandoc file.1 | col -bx | vim - 

The setting would thus be :

set makeprg=mandoc\ -K\ utf-8\ -Tutf8\ %\ \\\|\ col\ -bx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.