'VI editor - saving filename in :wq

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?



Solution 1:[1]

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

Solution 2:[2]

Enter :wq followed by file name to save the file

Eg:

:wq filename.txt

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GeneticSmart
Solution 2 Arun Joseph