मुझे नहीं पता लगता है कि ]m
मैपिंग के परिवार को अनुकूलित किया जा सकता है। ऐसे मामलों में, सामान्य अभ्यास कस्टम तर्क के साथ इसे ओवरराइड करना है। मैं कुछ vimscript के साथ आया कि क्या आप वर्णन करते हैं। असल में, यह घुंघराले ब्रेसिज़ के माध्यम से कूदता है और यह तय करने के लिए प्रासंगिक रेखा को देखता है कि क्या करना है। इस मामले में, यह सिर्फ "वर्ग" और "नेमस्पेस" घोषणाओं को अनदेखा करता है।
nnoremap <buffer> ]m :<c-u>call <SID>JumpMethod('{', 'W', 'n')<cr>
nnoremap <buffer> [m :<c-u>call <SID>JumpMethod('{', 'Wb', 'n')<cr>
nnoremap <buffer> ]M :<c-u>call <SID>JumpMethod('}', 'W', 'n')<cr>
nnoremap <buffer> [M :<c-u>call <SID>JumpMethod('}', 'Wb', 'n')<cr>
xnoremap <buffer> ]m :<c-u>call <SID>JumpMethod('{', 'W', 'v')<cr>
xnoremap <buffer> [m :<c-u>call <SID>JumpMethod('{', 'Wb', 'v')<cr>
xnoremap <buffer> ]M :<c-u>call <SID>JumpMethod('}', 'W', 'v')<cr>
xnoremap <buffer> [M :<c-u>call <SID>JumpMethod('}', 'Wb', 'v')<cr>
onoremap <buffer> ]m :<c-u>call <SID>JumpMethod('{', 'W', 'o')<cr>
onoremap <buffer> [m :<c-u>call <SID>JumpMethod('{', 'Wb', 'o')<cr>
onoremap <buffer> ]M :<c-u>call <SID>JumpMethod('}', 'W', 'o')<cr>
onoremap <buffer> [M :<c-u>call <SID>JumpMethod('}', 'Wb', 'o')<cr>
function! s:JumpMethod(char, flags, mode)
let original_cursor = getpos('.')
if a:mode == 'v'
normal! gv
elseif a:mode == 'o'
normal! v
endif
while search(a:char, a:flags) > 0
if a:char == '}'
" jump to the opening one to analyze the definition
normal! %
endif
let current_line = line('.')
if getline(current_line) =~ '^\s*{'
" it's alone on the line, check the above one
let method_line = current_line - 1
else
let method_line = current_line
endif
let method_line_body = getline(method_line)
if method_line_body =~ '\k\+\s*(.*)' && method_line_body !~ '\<\(for\|foreach\|if\|while\|switch\|using\|catch\|get\|set\)\>'
" it's probably a function call
if a:char == '}'
" we need to go back to the closing bracket
normal! %
endif
echo
return
else
if a:char == '}'
" we still need to go back to the closing bracket
normal! %
endif
endif
endwhile
" if we're here, the search has failed, restore cursor position
echo
call setpos('.', original_cursor)
endfunction
ध्यान रखें कि मैं वास्तव में, सी # का एक बहुत पता नहीं है, तो यह सभी मामलों में ठीक से काम नहीं हो सकता है, लेकिन अगर आप मुझे उस तोड़ने उदाहरण देना, मैं कुछ यह पता लगाने के लिए सक्षम हो सकता है में भालू।
इसे आजमाने के लिए, आपको इसे "vs.vim" के रूप में अपनी vimfiles निर्देशिका में "ftplugin" के नीचे कहीं भी रखना चाहिए। "Cs" से शुरू होने वाले किसी भी अन्य फ़ाइल नाम और ".vim" में समाप्त होता है, यदि आपके पास पहले से "cs.vim" फ़ाइल है।
में इन मैपिंग (एक और जवाब से इस सवाल का लिया गया) का उपयोग कर रहा जावा विकास के लिए, अपने आईडीई में आप विम की तरह शैली आदेश, इंटेलीजे और अन्य IDEs विम प्लगइन्स जो इन आदेशों की पेशकश है। शायद एक विजुअल स्टूडियो प्लगइन है जिसमें यह आदेश उपलब्ध होगा और उम्मीद के अनुसार काम करेगा। आप किस आईडीई का उपयोग कर रहे हैं? या आप कमांड लाइन से विम का उपयोग करते हैं? –
@Gweebz - मैं कोड संपादित करने के लिए जीवीआईएम का उपयोग कर रहा हूं, इसलिए मैं एक वीम प्लगइन पसंद करूंगा :) – mMontu