Skip to content

Commit

Permalink
Merge pull request #5 from mikinovation/fix/rename-filepath
Browse files Browse the repository at this point in the history
fix: rename file path
  • Loading branch information
mikinovation committed Jun 2, 2024
2 parents b7d9127 + 98276f1 commit 0cab335
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions config/nvim/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@ set noswapfile
" leaderをスペースへ設定
let mapleader = "\<Space>"

" 現在開いているファイル名の変更
command! -nargs=1 RenameFile call s:RenameFile(<f-args>)

function! s:RenameFile(new_name)
execute ':f ' . a:new_name
let l:current_file_dir = expand('%:p:h')
let l:new_file_path = l:current_file_dir . '/' . a:new_name
execute ':saveas ' . l:new_file_path
call delete(expand('#'))
execute ':w'
endfunction

:nmap <Leader>rf :RenameFile<Space>
:nmap <Leader>rf :call <SID>RenameFile(input('New file name: '))<CR>
" file explorerを開く
:nmap <Leader>e <Cmd>CocCommand explorer<CR>
Expand Down

0 comments on commit 0cab335

Please sign in to comment.