Pokazywanie postów oznaczonych etykietą vim. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą vim. Pokaż wszystkie posty

czwartek, 13 marca 2014

OMG ... vim ... and spaces ...

Simple shot.

File, in file some columns, where one line looks like this (some part from
psql -l -U username)

 niet            | niet    | UTF8
 postgres    | postgres | UTF8
 template0  | postgres | UTF8
 template1  | postgres | UTF8
 testowa     | postgres | UTF8
 testowa1   | mzdw     | UTF8
 testowisko | postgres | UTF8

I need only 1st word from line.

Commands
:1 (move to 1st line)
V (select line)
G (move to end of test and also keep selected)

Then press : (will see this->     :'<,'>   )

Type: s/ .*// and press Enter

And all go off ;)
Why ?

Thats why, because 1st character is a space before 'niet, and other dbnames'.

Press u (it will undo changes).

Now, let be a little smart ;) ?????

:1
V
G
:'<,'>s/^ // | '<,'>s/ .*//g

Tap enter and again enter :D


Uff ;)