Skip to content

Instantly share code, notes, and snippets.

@zbyna
Last active August 27, 2020 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbyna/621a2a8ae3cd7db86dbeffee9d1174eb to your computer and use it in GitHub Desktop.
Save zbyna/621a2a8ae3cd7db86dbeffee9d1174eb to your computer and use it in GitHub Desktop.
substitute command :s with script
" pokus - 1 search for items with at least 1 char between asterisks eg: not **
" 2 substitute them with the same string with stripped spaces
" list - mujList - is here for testing purposes
let flags = ''
let mujList = []
call cursor(1,1)
while search('\*\(.\{-}\)\*', flags,line("$")) > 0
" last search register "/
let @/='\*\(.\{-}\)\*'
" trigger next search using gn object and copy it
execute ':normal! ygn'
" result of copying is in register"0
let pomS = trim(@0,"* ")
if strchars(pomS) > 0
call add(mujList,[ @0,pomS] )
execute ":normal! ct**".pomS."\e"
endif
endwhile
echo mujList
echo "xxx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment