I am tidying up my vimrc.
Mission:
- Copy content inside single-quotes (and preferably after the slash)
- Paste them below line 1
1: Name:
2:
3: Bundle 'tpope/vim-rails'
4: Bundle 'tpope/vim-endwise'
5: Bundle 'mileszs/ack.vim'
6: Bundle 'scrooloose/nerdcommenter'
7: Bundle 'kana/vim-textobj-entire'
8: Bundle 'kana/vim-textobj-user'
I know about the
:{source_address}t{target_address}
Ex command, and I know it accepts patterns. However, I am still not able to get it just right. I am also fairly new to regexes so bear with me. I tried something along the lines of (on a visual selection
:'<,'>/\/.*\'t1
Where I attempt to match a pattern that:
Obviously I am off by some degree. Any ideas?
:t
copy the whole line, not the matchstr
to achieve what you want, you need matchstr()
function.
this line will do the similar thing, but in reverse order. Hope it is ok for you:
:'<,'>g/\/.*'/call append(1,matchstr(getline('.'),@/))
for example, if I just select the first two "Bundle" lines, and execute the cmd, I get:
1: Name:
/vim-endwise'
/vim-rails'
2:
3: Bundle 'tpope/vim-rails'
4: Bundle 'tpope/vim-endwise'
.... (other lines)
you see that the order was in reverse.
To keep the order you have options :
'<,'>g/.*/m1
2put! x