A few weeks back a few folks in the NetDevOps Live! Webex Teams Room were talking about source-code editors — how we got started, what text editing tool we started with, what we are using today — with a little of the why we use these (spoiler alert, its mostly personal preference). We all started on a similar path with VIM, and it is a great tool! VIM allows you to be efficient by forcing you to only use the keyboard, but we discovered that all of us had moved away from VIM. We still would use it for quick fixes and edit’s, or when we had logged into a remote machine/device and no source-code editor s installed. Bottom line, you always need to know VIM (or Nano), even the very basics.
The general consensus in our chat was that we had all moved on to a source-code editor. (Funny enough we all tried Sublime Text first, then Atom both of these are great editors and personally I ran some good mileage on both.) As fate would have it, we discovered all of us had moved to VScode. Others in the chat had done this way before me. I was a newbie, and some great insight and sharing was done between us on how we each set up our VScode environments.
Setting up my VSCode
First things first, I wanted a dark theme. (When your Twitter name is @bigevilbeard, having a dark mode on everything and dark theming is … well, it just fits. I went with “Material Theme” darker, it’s a quick install via the VScode Marketplace.
The next must-have for me was indent-rainbow. This extension colorizes the indentation in front of your text alternating four different colors on each step, it is helpful in writing code for Python. Having spent a few hours (OK days sometimes) troubleshooting/debugging code only to find out I had a space in the wrong place, has made me a fan of this feature.
Along the same thread, VSCode provides a way to automate the deletion of trailing spaces by using the Trim Trailing Whitespace command. (Depending on your settings, it may be more handy to just highlight them and/or delete them by hand, at any time.) This plug-in provides just that, and a lot of options to fine-tune the way you want to decimate trailing spaces.
Finally, one of the big reasons I moved to VSCode was the terminal. Before, I was using the native terminal/Python repl on my MacBook, but on demos and webinars for DevNet I found this was not the best visually.
I am using bpython too, bpython is a fancy interface to the Python interpreter for Linux, BSD, OS X, and Windows (with some work). bpython is released under the MIT License. It has the following ‘special’ features:
- In-line syntax highlighting
- Readline-like autocomplete with suggestions displayed as you type
- Expected parameter list for any Python function
- “Rewind” function to pop the last line of code from memory and re-evaluate
- Send the code you’ve entered off to a pastebin
- Save the code you’ve entered to a file
- Auto-indentation
- Python 3 support
I was able to color the terminal too, which makes this really pop when doing demos and webinars. This took me a few minutes to work out, but this was really worth the time. To do this, first head over to https://glitchbone.github.io/vscode-base16-term/#/ and select your terminal color. Search for “workbench: color customizations” and open the settings.json file. Then Edit or Paste your configuration under workbench.colorCustomizations.
Suggestions?
I am scratching the surface here, there are loads of cool extensions to make your development life easier. If you know any super extensions, please comment them below. In the next blog, I will be exploring how we can review and manage pull requests in GitHub with VSCode.
Related resources
- DevNet Networking Dev Center
- DevNet Network Automation Exchange
- DevNet certifications exam topics and study materials
One suggestion for an extension that seems popular is remote development: https://code.visualstudio.com/docs/remote/remote-overview . Take a look.
Thank you, this looks awesome!
Thanks for taking the time to show us all this! I intend to use it!
Thanks for reading!
I'll give you my secret(not really) extension recipe:
Bracket Pair Colorizer
Bookmarks
Better Comments
Indenticator
Highlight Line
Happy VSCoding =)
I love it! Thanks for sharing. 🙂
Prettier, Material Icons, Peacock etx.
I like the looks of Peacock, great suggestions – thanks!
Very good article, and perfectly working on my mac
Thanks!
Import cost
Interesting.. looking at this now. Thanks!
The Python package 'black' for code formatting in VS Code is nice