How can I write the output of a vim command to a register without newlines?

This is due to this question: How to redirect the output of an ex command to the current buffer or file?

However, the problem with use :rediris that 3 or 4 additional lines of a new line are output before the output, and it is difficult to remove them using the replace function.

For example, if I do the following:

:redir @a  
:pwd  
:redir END 

The content @aconsists of three blank lines and then the normal expected output.

I tried to publish a process with something like this:

:let @b = substitute(@a, '\s*\(.\{-}\)\s*', '\1', '')

But the result is that it @bhas the same content as @a.

Does anyone know a more efficient (i.e. working) post-process method or replacement for :redirone that doesn't have these extra lines?

+5
1

b a, .

:

:let @b = substitute(@a,'\_s*\(.\{-}\)\_s*$','\1','')

, , . g ( ) , , (%^), (%$).

substitute(@a,'\v%^\_s+|\_s+%$','','g')

\v, %^, +, | %$.

\_s \n, / ( SP, TAB NL).

+4
source

All Articles