How to make a list from a tabular text using VIM -
How to make a list from a tabular text using VIM -
i have text this:
uuu f cuu l auu guu v uuc f cuc l auc guc v uua l cua l aua gua v uug l cug l aug m gug v and want create this:
'uuu': 'f', 'cuu': 'l', 'auu': 'i', 'guu': 'v', 'uuc': 'f', 'cuc': 'l', 'auc': 'i', 'guc': 'v', 'uua': 'l', 'cua': 'l', 'aua': 'i', 'gua': 'v', 'uug': 'l', 'cug': 'l', 'aug': 'm', 'gug': 'v', what best way using vim?
there lot of ways in vim. 1 way utilize substitution.
:%s/\(\w\w\w\) \(\w\)\_s*/'\1': '\2',\r/g this looks 3 letters followed space followed letter , place first 3 letter in first capture grouping (\1) , single letter sec capture grouping (\2). consume trailing whitespace (including newlines \_s*).
this replaced '\1': '\2',\r \r newline.
vim
Comments
Post a Comment