चयनित टेक्स्ट को बाईं ओर 4 रिक्त स्थान पर स्थानांतरित करने के लिए मैं शिफ्ट-टैब कैसे प्राप्त कर सकता हूं?एएमएक्स शिफ्ट-टैब ब्लॉक को बाएं स्थानांतरित करने के लिए
उत्तर
यह वर्तमान रेखा के सामने से 4 रिक्त स्थान हटा देता है (रिक्त स्थान मौजूद हैं)।
(global-set-key (kbd "<S-tab>") 'un-indent-by-removing-4-spaces)
(defun un-indent-by-removing-4-spaces()
"remove 4 spaces from beginning of of line"
(interactive)
(save-excursion
(save-match-data
(beginning-of-line)
;; get rid of tabs at beginning of line
(when (looking-at "^\\s-+")
(untabify (match-beginning 0) (match-end 0)))
(when (looking-at "^ ")
(replace-match "")))))
अपने चर tab-width
4 होता है (और है कि क्या आप "पूर्ववत करें" करना चाहते हैं), तो आप और अधिक सामान्य की तरह (concat "^" (make-string tab-width ?\))
कुछ के साथ (looking-at "^ ")
बदल सकते हैं।
इसके अलावा, कोड untabify का उपयोग करके रिक्त स्थान पर टैब के सामने टैब को रूपांतरित करेगा।
ऐसा करने के लिए, मैं indent-rigidly
कमांड का उपयोग करता हूं, C-x TAB
से जुड़ा हुआ है। चयनित क्षेत्र को बाईं ओर चार स्थानों पर बाईं ओर ले जाने के लिए तर्क -4 दें: C-u -4 C-x TAB
।
http://www.gnu.org/s/emacs/manual/html_node/elisp/Region-Indent.html
उसी मैन्युअल प्रविष्टि के अनुसार, आप' इंडेंट-कोड-कठोर रूप से ' 'क्योंकि यह अकेले टिप्पणियां और मल्टी-लाइन तारों को छोड़ देता है – toolbear
मैं अगर आप टैब या Shift + Tab का उपयोग पर निर्भर करता है बाएं या दाएं चार रिक्त स्थान से किसी क्षेत्र के ऊपर टैब के लिए कुछ कार्यों बनाया:
(defun indent-region-custom(numSpaces)
(progn
; default to start and end of current line
(setq regionStart (line-beginning-position))
(setq regionEnd (line-end-position))
; if there's a selection, use that instead of the current line
(when (use-region-p)
(setq regionStart (region-beginning))
(setq regionEnd (region-end))
)
(save-excursion ; restore the position afterwards
(goto-char regionStart) ; go to the start of region
(setq start (line-beginning-position)) ; save the start of the line
(goto-char regionEnd) ; go to the end of region
(setq end (line-end-position)) ; save the end of the line
(indent-rigidly start end numSpaces) ; indent between start and end
(setq deactivate-mark nil) ; restore the selected region
)
)
)
(defun untab-region (N)
(interactive "p")
(indent-region-custom -4)
)
(defun tab-region (N)
(interactive "p")
(if (active-minibuffer-window)
(minibuffer-complete) ; tab is pressed in minibuffer window -> do completion
; else
(if (string= (buffer-name) "*shell*")
(comint-dynamic-complete) ; in a shell, use tab completion
; else
(if (use-region-p) ; tab is pressed is any other buffer -> execute with space insertion
(indent-region-custom 4) ; region was selected, call indent-region
(insert " ") ; else insert four spaces as expected
)))
)
(global-set-key (kbd "<backtab>") 'untab-region)
(global-set-key (kbd "<tab>") 'tab-region)
संपादित: करने के लिए जोड़ा गया Maven का कोड जांचें कि मिनीबफर में, साथ ही विशिष्ट बफर (खोल) में टैब पूर्ण होने के लिए, उदाहरण के लिए)।
अच्छा, स्वीकार्य उत्तर केवल 1 लाइन के लिए काम कर रहा था, न कि क्षेत्रों –
परफेक्ट। क्षेत्रों और रेखाओं के लिए काम करता है। अन्य सामान्य संपादक की कार्यक्षमताओं को दोहराता है। – mythicalcoder
मैंने स्टेनली बेक के जवाब पर सुधार किया है। मेरे लिए, यह वैश्विक कुंजी बाध्यकारी मिनीबफर पूरा करने में गड़बड़ कर रहा था।
इसलिए मैंने मिनीबफर के लिए भी एक मामला शामिल किया है।
संपादित करें: indent-region
->indent-region-custom
का नाम बदलें।
indent-region
मौजूदा कमांड के साथ संघर्ष कर रहा है और इंडेंट के लिए त्रुटि (सहेजने से पहले हुक) और कुछ अन्य महत्वपूर्ण संयोजनों पर त्रुटि देता है।
(defun indent-region-custom(numSpaces)
(progn
;; default to start and end of current line
(setq regionStart (line-beginning-position))
(setq regionEnd (line-end-position))
;; if there's a selection, use that instead of the current line
(when (use-region-p)
(setq regionStart (region-beginning))
(setq regionEnd (region-end))
)
(save-excursion ; restore the position afterwards
(goto-char regionStart) ; go to the start of region
(setq start (line-beginning-position)) ; save the start of the line
(goto-char regionEnd) ; go to the end of region
(setq end (line-end-position)) ; save the end of the line
(indent-rigidly start end numSpaces) ; indent between start and end
(setq deactivate-mark nil) ; restore the selected region
)
)
)
(defun untab-region (N)
(interactive "p")
(indent-region-custom -4)
)
(defun tab-region (N)
(interactive "p")
(if (active-minibuffer-window)
(minibuffer-complete) ; tab is pressed in minibuffer window -> do completion
(if (use-region-p) ; tab is pressed is any other buffer -> execute with space insertion
(indent-region-custom 4) ; region was selected, call indent-region-custom
(insert " ") ; else insert four spaces as expected
)
)
)
(global-set-key (kbd "<backtab>") 'untab-region)
(global-set-key (kbd "<tab>") 'tab-region)
- 1. एएमएक्स
- 2. समीकरणों के ब्लॉक को बाएं संरेखित करें
- 3. एएमएक्स 23
- 4. एनीमेशन: दृश्य लोड होने पर यूआईबटन को दाएं से बाएं स्थानांतरित करने के लिए कैसे करें?
- 5. प्रोटोबफ परिभाषाओं को स्थानांतरित करने के लिए
- 6. ग्रहण की स्लाइड ब्लॉक के लिए ग्रहण कीस्ट्रोक बाएं/दाएं
- 7. निर्देशिका स्थानांतरित करने के लिए लिनक्स कमांड
- 8. बैश कमांड केवल कुछ फाइलों को स्थानांतरित करने के लिए?
- 9. डीजेगो मॉडल प्रमाणीकरण को स्थानांतरित करने के लिए निष्क्रिय तरीका
- 10. ऑब्जेक्ट को विशिष्ट स्थानों में स्थानांतरित करने के लिए cocos2d
- 11. वस्तुओं को स्थानांतरित करने के लिए स्थानिक डेटा संरचनाएं?
- 12. क्या श्रेणियों को स्थानांतरित करने के लिए कोई एल्गोरिदम है?
- 13. जावा: बड़ी फ़ाइलों को स्थानांतरित करने के लिए निर्देशिका देखना
- 14. पुटीटी शॉर्टकट्स को छोटा करने, अधिकतम करने, पुनर्स्थापित करने और विंडो को स्थानांतरित करने के लिए
- 15. कीबोर्ड स्लाइडआउट UIWebView को बाएं
- 16. jQuery को बाएं से दाएं छवि को एनिमेट करने के लिए jQuery?
- 17. विम प्रश्न: कोड के ब्लॉक को ब्लॉक करना
- 18. अंतर ब्लॉक करने के लिए libwww-पर्ल
- 19. प्री ब्लॉक जैसे div को प्रारूपित करने के लिए कैसे?
- 20. रूबी - विधियों को पास करने के लिए ब्लॉक
- 21. वीएचडीएल ब्लॉक आरेखों को आकर्षित करने के लिए कार्यक्रम?
- 22. अंततः ब्लॉक को पकड़ने के लिए अंत में ब्लॉक करें
- 23. ब्लॉक या कोशिश/पकड़ ब्लॉक को छोड़कर __try/__ का उपयोग करने के लिए बेहतर क्या है?
- 24. कुछ एएमएक्स इनिट कमांड केवल जीयूआई मोड
- 25. काम करने के लिए बाएं बाहरी जॉइन में समस्याएं
- 26. दाएं से बाएं करने के लिए भाषा ब्रैकेट उलट
- 27. नियंत्रकों और मॉडलों के लिए पुन: प्रयोज्य कोड को स्थानांतरित करने के लिए कहां
- 28. कैसे प्रोग्राम के रूप में स्थानांतरित करने के लिए विंडोज़ टास्कबार (दो लेने के लिए)
- 29. बाएं से बाएं UILabels
- 30. ब्लॉक के लिए कमरे देने के लिए आवश्यक लाइनें बनाते समय ब्लॉक को पेस्ट कैसे करें?
अच्छा! लेकिन मैं आईएफ के बजाय WHEN का उपयोग करूंगा, क्योंकि कोई और खंड नहीं है। मेरे लिए – Ken
, यह किसी चयनित क्षेत्र के साथ काम नहीं करता है। केवल पहली पंक्ति के साथ: -/ – Ismael
मेरे लिए, यह बिल्कुल काम नहीं करता है। :( –