Rangerがとても便利だったので,主にそれの紹介です.
私がファイルに書き始めるまでをその時系列に沿って説明します.
1. Ranger
- 1.1 直接ファイルを開く場合.コマンドは
l
です.l
にはnvimが登録されています. - 1.2 作業ディレクトリを開く場合
S
で移動した後に$nvim hoge.txt
とファイルを開くこともあります.その場合,以下の操作はいりません. - 1.3 Gvim(nvim-qtなど)の場合 ranger-vimを使用して,1.1と同様にファイルを開きます.
2. 作業ディレクトリの移動(1.1, 1.3)
1.1, 1.3の場合vim内の作業ディレクトリを移動する必要があります.自作コマンド:CD
(以下)を実行します.
init.vim
" define current directory {{{
" 参考: https://vim-jp.org/vim-users-jp/2009/09/08/Hack-69.html
command! -nargs=? -complete=dir CD call s:ChangeCurrentDir('<args>')
function! s:ChangeCurrentDir(directory)
if a:directory == ''
lcd %:p:h
else
execute 'lcd' . a:directory
endif
if exists("g:NERDTree")
exe "normal \<Plug>NerdTreeCWD"
endif
endfunction
" }}}