Skip to content

Commit

Permalink
fix: rename file path
Browse files Browse the repository at this point in the history
  • Loading branch information
mikinovation committed Jun 2, 2024
1 parent f3482b9 commit 98276f1
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 98276f1

Please sign in to comment.