2014-06-21 6 views
6

अधिक जटिल search & replace वीम में ऑपरेशन करते समय मैं अक्सर इसे search में आज़माता हूं और केवल तभी मिलता है जब मुझे लगता है कि मैं search & replace का उपयोग करता हूं।विम में खोज में उपयोग की जाने वाली अंतिम अभिव्यक्ति का उपयोग कैसे करें?

वहाँ एक रास्ता कैसे search से अंतिम मान पहुँच सकते हैं और यह search & replace में डाल दिया या वैकल्पिक रूप से, एक register में इस अंतिम मान डाल करने के लिए है?

उत्तर

4
VIM wiki page से

:

:%s//<c-r>//g 
    Replace each match of the last search pattern with the/register (the last search pattern). 
    After pressing Ctrl-R then/to insert the last search pattern (and before pressing Enter to perform the command), you could edit the text to make any required change. 
+1

अच्छा। मुझे नहीं पता था कि '/' भी पंजीकरण है। –

1

आप इसे छोड़ सकते हैं और vim पैटर्न के लिए पिछले खोज का उपयोग करेगा आप खोज regex संपादित करने की जरूरत नहीं है, तो।

:%s//<replacement>/ 

:h :s | /If the {pattern} से

If the {pattern} for the substitute command is empty, the command uses the 
pattern from the last substitute or `:global` command. If there is none, but 
there is a previous search pattern, that one is used. With the [r] flag, the 
command uses the pattern from the last substitute, `:global`, or search 
command. 
0

आप क्ष/ दबाकर आप अपने खोज इतिहास संपादित कर सकते हैं।

आपका खोज इतिहास एक अलग फ़ाइल में खुल जाएगा, लंबवत थूक जाएगा।

आप सामान्य विम सत्र की तरह प्रत्येक पंक्ति को नेविगेट और संपादित कर सकते हैं।

किसी खोज को निष्पादित करने के लिए, पर जाएं किसी भी पंक्ति पर दर्ज करें।

रद्द करने के लिए मारा :क्ष खोज इतिहास विंडो को बंद करने।

आप इस विंडो से और चीजों को कॉपी और पेस्ट कर सकते हैं।:

आप भी अपनी आदेश क्षदबाकर इतिहास संपादित कर सकते हैं।

संबंधित मुद्दे

 संबंधित मुद्दे