Open Files and Save Them to Disk

This post extracts some knowledge from Practical Vim Chapter 7 -- Open Files and Save Them to Disk.

[!TIP] Open a File by Its Filepath Using :edit

[!TIP] Open a File by Its Filename Using :find

[!TIP] Explore the File System with netrw

Ex Command Shorthand Effect
:edit . :e. Open file explorer for current working directory
:Explore :E Open file explorer for the directory of the active buffer

Think of each window as a playing card. One side of the card shows the contents of a file, and the other side shows the file explorer. After summoning the file explorer view, if we decide that we want to switch back to the buffer we were already editing, we can do so using the <C-^> command.

[!TIP] Save a File as the Super User

:w !sudo tee % > /dev/null

We can set keymap at vimrc config file with :W:

command! W execute 'silent w !sudo tee % > /dev/null' | edit!

原文链接:https://zhuang.dev/reading/practical-vim/07-open-files-and-save-to-disk/

posted @ 2026-07-12 22:50  neozhuang  阅读(5)  评论(0)    收藏  举报