Wednesday, July 9, 2014

RE: Clean string returned by windows console cmd

Ni Va wrote:
> Your command is pretty good but can I affect a variable
> instead of output command under the cursor into the buffer

You have to do some work.

:new
:r !wmic logicaldisk get deviceid
:1,2d
:%s/\s\+$//e
:let drives = getline(1,'$')
:echo drives

Select the above text and yank it (type yip).
Then type :@" to execute the yanked text.

The result is that a variable named drives is a list of the
drive letters, for example:

:echo drives
['C:', 'D:', 'E:']

John


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: