इसे आजमाइए। यह फिर से समाप्त हो जाता है @ताकि g@(इसके अलावा एक डमी गति l) का उपयोग किया जाता है, इस प्रकार अंतिम ऑपरेटर बन जाता है और इसके साथ दोहराता है .।
" When . repeats g@, repeat the last macro.
fun! AtRepeat(_)
" If no count is supplied use the one saved in s:atcount.
" Otherwise save the new count in s:atcount, so it will be
" applied to repeats.
let s:atcount = v:count ? v:count : s:atcount
" feedkeys() rather than :normal allows finishing in Insert
" mode, should the macro do that. @@ is remapped, so 'opfunc'
" will be correct, even if the macro changes it.
call feedkeys(s:atcount.'@@')
endfun
fun! AtSetRepeat(_)
set opfunc=AtRepeat
endfun
" Called by g@ being invoked directly for the first time. Sets
" 'opfunc' ready for repeats with . by calling AtSetRepeat().
fun! AtInit()
" Make sure setting 'opfunc' happens here, after initial playback
" of the macro recording, in case 'opfunc' is set there.
set opfunc=AtSetRepeat
return 'g@l'
endfun
" Enable calling a function within the mapping for @
nno <expr> <plug>@init AtInit()
" A macro could, albeit unusually, end in Insert mode.
ino <expr> <plug>@init "\<c-o>".AtInit()
fun! AtReg()
let s:atcount = v:count1
let c = nr2char(getchar())
return '@'.c."\<plug>@init"
endfun
nmap <expr> @ AtReg()
मैंने जितने कोने के मामलों को संभालने की कोशिश की है, मैं सोच सकता हूं। आप के @:साथ दोहरा सकते हैं .। के बाद के प्रेस के लिए मायने रखता है @या .बनाए रखा जाता है .।
यह मुश्किल है, और मुझे यकीन नहीं है कि कुछ रास्ते में कहीं नहीं टूटेगा। इसलिए इस के साथ कोई गारंटी, वारंटी या वादे नहीं हैं।
व्यक्तिगत रूप से, मैं .पिछले बदलाव के लिए ठीक-ठीक दोहराए गए और मैक्रो के दोहराव के बीच अंतर कर रहा हूं @@।
संपादित करें
मुझे लगा, बहुत दूर जाने के बाद, मैं कुछ अतिरिक्त कोड जोड़ सकता हूं जो .इसे वापस खेलने के लिए मैक्रो रिकॉर्ड करने के तुरंत बाद दबाने की अनुमति देगा ।
fun! QRepeat(_)
call feedkeys('@'.s:qreg)
endfun
fun! QSetRepeat(_)
set opfunc=QRepeat
endfun
fun! QStop()
set opfunc=QSetRepeat
return 'g@l'
endfun
nno <expr> <plug>qstop QStop()
ino <expr> <plug>qstop "\<c-o>".QStop()
let s:qrec = 0
fun! QStart()
if s:qrec == 1
let s:qrec = 0
return "q\<plug>qstop"
endif
let s:qreg = nr2char(getchar())
if s:qreg =~# '[0-9a-zA-Z"]'
let s:qrec = 1
endif
return 'q'.s:qreg
endfun
nmap <expr> q QStart()
Enter