#NAVdevTips 15: Hit F12 – some tricks in VSCode
For all of us Visual Studio Code is still new editor and we need to used to it. Luckily it has much more to offer than our old editor. Even if I am not using all it’s power and functions I must say I really like it. And I still learning (or someone teach me) new things. So I decided to share with you with some Tips and Tricks related to VSCode but not directly to AL.
For some of you below shortcuts will be basics but I am know that when you start it is good to have some idea what you can do.
This combination is used by me the most. How many times you were thinking what should be put in here? If you will use Ctrl+Space you will see options which you have. It is useful when you write code but also when you not sure what you can put in app.json file or launch.json file.
Shortcut: F12 – Go to definition
I put it in title because I think it is very cool (Thx Patryk for showing it). How does it work? If you stand on any variable then after hit F12 you will be moved to place where you defined the symbol. But what is cool in this is when you will click it second time when you are on any Record, Codeunit or other object you will see that object – even standard one!
However do not expect whole code to be shown for standard objects – you will see only necessary things like table fields, keys or all integration events.
Shortcut: Alt+Shift+F – Format Document
This shortcut is something which I use very often. I really do mess when develop and I am really happy that I can easily fix all without thinking how I should format document.
Some comment to this. Sometimes, in my opinion, it is not formatting document well (at least in NAV 2018 AL language). For example case statement looks weird. Also I think something is wrong with if statement when you use brackets in it. But – I made a rule in our company that we format as it is so each document after development must be formatted with this function. Then we sure all objects look the same.
Shortcut: F2 – Rename Symbol
Shortcut: Ctrl+F2 Change All Occurrence
If you have a function and want to change the name of it you can use shortcut F2. It will rename all places where you use the function.
Other option, which works similar to Find and Replace is shortcut Ctrl+F2 which find all occurrence of the word and gives you possibility to change it. This you can use on any word which you want not only on functions. You will need to used to it but it is very useful function – word is already marked so if you do not want to delete it then first click right arrow to unmark it and then you can correct the word.
Shortcut: Shift+F12 – Find all Reference
This shortcut will help you to see all places in a document where the variable has been used. On right side you will see where it was used and you can jump directly to the line.
Shortcut: Shift+Ctrl+F – Find in all objects
Shortcut: Shift+Ctrl+H – Replace in all objects
It is good to know that you can find and/or replace word in all objects at the same time. This is also very useful especially when you need to replace in all files one field name or other thing like name of variable.
If you need to add fields or controls very fast, multiple times and later just change the values instead of using snippets you can click Alt+Shift+Down (or Up) and then you will get as many the same lines as you want.
More useful functions
Hopefully you find all those shortcuts useful. If you want to try more nice features you can go to home page. On right side there is interactive playground and also place where you can change the color of your VSCode.
nice tips mate! thanks 🙂