Copy the appropriate text for registration

Does anyone know if it is possible to combine matches from a search into a single register? For example, I have a file with the following contents:

aaa :xxx 123
bb :y 8
ccccc :zzzzz 1923

Now I want to copy the column starting with ':' elsewhere. Unfortunately, I cannot use the visual block mode because the first column does not have a fixed width. I thought that I could find the second column (: \ w +) and save it in the registry.

+5
source share
4 answers

Another way:

:g/:/norm f:"Aye

Per :h quote_alpha, , , . "a,

:xxx:y:zzzzz

(, , , cpoptions).

+8

:

qa ( a).

"Rye (yank r-capital append, .)

n ( )

q ( )

10 , 10 @a , r , .

+2

.vimrc vim .
.vimrc CopyTextAfterColon, , .

  function! s:copy_after_colon()
    let values = ''

    let pattern = '^.*:\(\w\+\).*$'

    for line_number in range(1, line('$'))
        let line = getline(line_number)
        if line =~ pattern
            let value = substitute(line, pattern, '\1', '')
            let values .= value."\n"
        endif
    endfor

    let @* = values
endfunction

command! -nargs=0 CopyTextAfterColon call <SID>copy_after_colon()

.

+1

. TextFieldReader , CSV:

using Microsoft.VisualBasic.FileIO;

TextFieldParser reader = new TextFieldReader("C:\MyFile.txt");
reader.Delimiters = new string[] { " " };
string[] currentRow = null;
while (!reader.EndOfData)
{
    try
    {
        currentRow = reader.ReadFields();
        foreach(string field in currentRow)
        {
            //save this field...
        }
    }
    catch (MalformedLineException ex)
    {
        //handle exception the way you want
    }
}

, . , , , . .

EDIT: , , #. - .

0

All Articles