I pasted some code into a new, unwritten buffer in Vim. I'd like to do some quick edits on the code without saving it to a file, but it hurts my eyes to look at code without syntax highlighting. Can I use syntax highlighting without writing it to a file? I don't want to write it to a file so I don't have to delete the file when I'm done.
In addition to setting the syntax, setting the filetype brings indent options (if you have those on), mappings, and other filetype specific vimscript to bear on your code. So I recommend
Which we typically abbreviate in interactive use as
You can set the syntax highlighting by doing:
This will work in the unwritten buffer. Change
java for the appropriate value.