How to save your code in linux on terminal

how to save what you code on linux mate terminal so that you can see your codes and save them.I am an entry level coder and hence, am not sure on the category

What editor are you using? It should have some way of a saving/reading a text file

I use pluma by ubuntu mate however should i select all code in the terminal and paste it in the text editor to save it?

You sound like you are using Swift as an interpreter. The normal mode is to put your program in text file, compile it, and run it. So, you would use pluma to write your program. Save is as .swift file. I think you can use swift run <your program>.swift to run it, or use swift/swiftc to compile it. There should be beginner tutorials on the Internet on how to use various compile/run modes of Swift.

ok thank you ,will try