With the plethora of programming that we promote at Null Byte, I figured a lot of you newbies that stop by IRC will need a big boost in the right direction to make your dive into programming a lot easier. A hot question that has been thrown around in IRC a lot when making the initial dive is, "How do I write code?". People who do not know much about computers can't understand how code is written. Code that we write here is usually scripted and written in Python, so we will use it as our example language.
Code can be written in any old text editor. Even Windows Notepad will do. I am writing this guide for Linux users because everyone who has been in the programming sessions have switched to Arch, or some other form of Linux, and Windows users can just use Notepad++.
You have a choice when it comes to how you want to type code. We can use a simple syntax highlighting editor (like we are preparing to do) or we could use an IDE (Intergrated Development Environment). An IDE has all sorts of features (code completion), but they tend to be bloated.
Today's Null Byte is going to focus on syntax highlighting. Syntax highlighting is a helpful feature that will color code certain significant words in a given programming language. This makes code easier to read and keep organized. Here is an example of what we are going to make the nano text editor appear as below when it displays Python code.
Text in bold is a terminal command.
- Installed copy of nano
sudo pacman -S nano
- Linux OS
- In your home directory, we need to create a .nanorc file, because it likely doesn't exist. If it does, just edit it.
cd ~/ && nano .nanorc
- Open another terminal. We are going to use the default Python script for nano.
- Paste the contents into your .nanorc file. You can also use this command.
sudo echo $(cat /usr/share/python.nanorc) >> ~/.nanorc
- Now, exit your terminal, and open another.
- Start typing Python-related commands, like print and you will see them become highlighted. Pretty cool, eh?
Want to start making money as a white hat hacker? Jump-start your hacking career with our 2020 Premium Ethical Hacking Certification Training Bundle from the new Null Byte Shop and get over 60 hours of training from cybersecurity professionals.
Other worthwhile deals to check out: