LoginSignup
0
0

More than 5 years have passed since last update.

VimでEmacsのFind Alternate fileを実現

Last updated at Posted at 2014-12-13

これは何か?

開くファイルを間違えた時に、正しいファイルで開き直すための機能が、どうやら Vim には無いようです。

Emacs から Vimに乗り換えて一週間、Vim script を勉強しつつ書いてみました。

ソース

command! -nargs=1 -complete=file FindAlternateFile call <sid>Hykw_findAlternateFile(<q-args>)

function! Hykw_findAlternateFile(file)
  let current_bufferNumber = bufnr('%')
  execute "edit " . a:file
  execute "bdelete " . current_bufferNumber
endfunction

使い方

.vim の適当な所にソースを貼り付ければOKです。あとはファイルを間違えて開いた時に

:FindAlternateFile 開き直すファイル名

で呼び出します。ちなみにTabでディレクトリ/ファイル名の補完も効きます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0