Last active
August 27, 2020 23:47
-
-
Save zbyna/621a2a8ae3cd7db86dbeffee9d1174eb to your computer and use it in GitHub Desktop.
substitute command :s with script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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