私にはありません]m
マッピングのファミリをカスタマイズできると考えてください。このような場合、通常の方法はカスタムロジックでオーバーライドすることです。私ははあなたは何を記述する必要がありますいくつかのvimscriptを思い付いた。基本的に、中括弧を飛び越えて、関連する行を見て何をすべきかを決定します。この場合、単に "class"と "namespace"宣言を無視します。それはすべての場合に正しく動作しない場合がありますので、私は本当に、C#のの多くを知らないが、あなたは私に壊れ例を与えれば、私は何かを把握することができるかもしれない心の中で
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
ベア。
これを試してみるには、vimfilesディレクトリの "ftplugin"の下のどこかに "cs.vim"と書いてください。すでに "cs.vim"ファイルがある場合、 "cs"で始まり ".vim"で終わるその他のファイル名も適切です。
に(この質問に別の答えから取られた)これらのマッピングを使用しています。たぶん、このコマンドを利用できるVisual Studioプラグインがあり、期待どおりに動作します。どのIDEを使用していますか?あるいはコマンドラインからVimを使うだけですか? –
@Gweebz - コードを編集するためにgVimを使用していますので、Vimプラグインを好むでしょう:) – mMontu