CTRL-sを使用してvimに保存

CTRL-sを使用してvimに保存

ctrl- を押してs現在のファイルを保存するために.vimrcに次の行を追加しました。

:nmap <C-s> :w!<cr>
:imap <C-s> <esc>:w!<cr>

しかし、これはうまくいきません。私が何を間違っているかについての提案はありますか?

ベストアンサー1

実行する特定のタスクについては、このwikia.comの記事をご覧ください。http://vim.wikia.com/wiki/Map_Ctrl-S_to_save_current_or_new_files

つまり、次のことを行う必要があります。

1.に追加~/.vimrc

" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
nnoremap <silent> <C-S> :if expand("%") == ""<CR>browse confirm w<CR>else<CR>confirm w<CR>endif<CR>

2.Ctrl+の端末解析を無効にするS

# bash
# No ttyctl, so we need to save and then restore terminal settings
vim()
{
    local ret STTYOPTS="$(stty -g)"
    stty -ixon
    command vim "$@"
    ret=$?
    stty "$STTYOPTS"
    return "$ret"
}

# zsh
vim() STTY=-ixon command vim "$@"

おすすめ記事