VI editor - saving filename in :wq

4.9k views Asked by At

After typing whatever that I need in VI, i wanted to save it to a file with :wq filename. But if I have type in the wrong filename , there is no way for me to amend it.

Moving the cursor to yth character and typing x will replace the wrong character(yth) with x Pressing backspace or delete will just move the cursor left instead of removing the wrong character Pressing esc or back arrow will save the file

How do I change delete a wrong word/character in :wq wrongfilename ?

e.g: wq wrongfilename -- I want to remove filename , how do I do that?

2

There are 2 answers

0
Arun Joseph On

Enter :wq followed by file name to save the file

Eg:

:wq filename.txt

0
GeneticSmart On

Use shift key while pressing back arrow. This does the trick for me