简体   繁体   中英

why :e % doesn't work in Windows Vim

From time to time I use a :e % command. This command simply says

Edit current buffer

It worked on Linux and Mac machines, but recently I was forced to switch to a Windows machine and whenever I type :e % I get a list of environment variables. I do know that environment variables in Windows start with % . So how do I edit a current buffer in Windows in Vim ?

  How do I edit the current file in vim?

Well, In most cases, the current file is opened in a buffer and is the main file you are editing. If you want to edit the current file, press i to get into insert mode and change, or use commands to delete,copy, paste and add characters, blocks, lines, paragraphs of text. In case if your current file is only readable, you can still edit it and save it with a new name by typing :w newname . If you are particular that you want to use :e (edit) command to edit the file, you can directly give :e to edit the current file(buffer). Most commands in vim accept an argument. So, :e also accepts a filename as an argument and edits that file. If you dont provide any filename, then it takes the current buffer.

Even though :e is enough to edit the current file, if you are still eager to edit the file with % symbol, then, type :e and then press Ctrl<\\kbd>+R<\\kbd> and then % . It inserts the current file's name in command line. You can now edit it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM