• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

press the escape key from a text file in vim


I would like to create a text file, such that when I "cat" the file from xterm, it is as if I am pressing the <escape> button on my keyboard.  Is there a known way to do this?
  • 2
2 Solutions
echo -e "\033" >file
cat file

or simply

echo -e  "\033"

Why not use vim to add the character? You need to use CTRL-V CTRL-[ to add the escape character. Of course, if you're using the windows version, you may have CTRL-V remapped to paste, in which case the default replacement is CTRL-Q, i.e. type CTRL-Q CTRL-[ to add escape to the file.
Good point bpmurray.  I was looking at the question rather than the subject.

Just proves again that it is always better to describe the problem you are trying to solve rather than asking how to solve the way you think it should be done.
bryanlloydharrisAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now