Thursday, March 19, 2015

Re: Unknown vimrc line: %!awk

Am 2015-03-18 23:38, schrieb Christian Bone:
> I haven't used Vim in a while and when I started using it again I
> noticed this line in $MYVIMRC
>
> :nnoremap <f3> :%!awk '!a[$0]{a[$0]=1;print}'<bar>noh<cr>
>
> I understand that it's mapping to the F3 key, but I can't figure out
> what the rest of the line does. Can anyone tell me?

This pipes your current buffer through awk with the awk oneliner:

'!a[$0]{a[$0]=1;print}'

Which I believe is a kind of uniq function.

E.g. each line will be output, if awk hasn't seen it before.

After that the vim command <bar>noh<cr> is executed. I am not
quite sure about that one, I suspect it is trying to use :noh
(e.g. disable search highlighting using the :noh command), but
I wonder why the ':' is missing.

Best,
Christian

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