Snippet Suggestions in Visual Studio Code

Snippet Suggestions in Visual Studio Code

This is one of the shortest posts ever. Five minutes ago I was annoyed by Visual Studio Code’s default behavior when it comes to IntelliSense in combination with snippets.

Picture tell more than words, so I will show you an example. I have an OnAfterValidateTrigger and want to see the suggestions inside the brackets. When I hit Ctrl + Space to activate IntelliSense, the first suggestions are all snippets that do not make sense in this situation.

The first suggestion I would expect is the suggestion “var”. Unfortunately, it is at the bottom of this suggestion list. So i checked the settings and found a setting that is called Snippet Suggestions. By default, this setting is set to “inline”.

After changing that Snippet Suggestion setting to bottom, the order of my suggestions made more sense.

Here is a picture of the setting that you need to change.

Maybe all of you already know this and just laugh about this post, then that’s okay. If this helps even a single person that did not know this before, then the post was worth it.

Have a nice week!

3 thoughts on “Snippet Suggestions in Visual Studio Code

  1. I’m one of the ones who didn’t know 😉 – so thnx dude!
    i think i have to look more in the settings

    1. Nice to hear that 🙂
      Yea, Visual Studio Code can do some interesting things if you are willing to investigate its functions and settings. The big question is: Who has the time to check all of these settings and functions?

  2. Slowly but surely, even the last dinosaur will venture out of the cosy safety of C/SIDE and C/AL to plunge death-defyingly onto the battlefield of the new programming language AL. Not everyone has the time to deal with all the VS Code Settings.

    It’s enough if a dumb guy like me has nothing better to do and writes it down for the others. That’s why I’ve summarized some important settings here that can save you a lot of time. Easy to digest and with great screenshots (semi srs). Please note that these are my personal suggestions. I find them useful, you do not have to agree with me.

    #1 Setting: Default Clone Directory

    The default location to clone a git repository.

    #2 Setting: Snippet Suggestions

    Controls whether snippets are shown with other suggestions and how they are sorted. Suggested value: Bottom

    The default value “inline” sorts the suggestions like shown in the screenshot (first snippets, then the last suggestion “var”).

    Changing the setting to “bottom” moves the last suggestion “var” to the top of the list.

    I dedicated a whole post on the snippet suggestions. For more information, check it out here.

    #3 Setting: Exclude

    Configure glob patterns for excluding files and folders. For example, the file Explorer decides which files and folders to show or hide based on this setting. Refer to the Search: Exclude setting to define search specific excludes. Read more about glob patterns here. Suggested value: Add folder “**/.alcache” to the excluded folders like on the screenshot.Thanks to Waldo for finding this gem. This will make it a lot easier to search stuff in your files.

    #4 Setting: Auto Save

    Controls auto save of dirty editors. Read more about autosave here. Suggested value: AfterDelay

    The value is automatically set to “afterDelay” if you activate “Auto Save” in the menu “File”.

    #5 Setting: Format On Save

    Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down. Suggested value: true

    This will automatically indent your code and format it when you save your files. Pretty useful!

    #6 Setting: Disable Default AL Snippets (CRS)

    Disable the default AL Snippets. When you change the setting, you need to restart VSCode twice. Once for disabling the snippets on activation (at that time, the snippets are still loaded). And the second time to actually not load the snippets anymore. Suggested value: trueNote: Make sure to set “Disable CRSSnippets” to false if you deactivate the default al snippets. Otherwise you may not have all important snippets anymore.

    This will declutter your snippets a lot. This way it is easier to decide which snippets to take.

    #7 Setting: Use Internal Navigation (AL Object Designer)

    Use custom Go To Definition feature. (Auto-enabled on Linux) Suggested value: false

    If your editor keeps opening new files when you hover over variables in your AL Code, then you might want to disable this option. The screenshot should speak for itself.

    #8 Setting: Fix Code Cop Missing Parantheses On Save (AZ AL Dev Tools)

    Fix Code Cop “Missing Parantheses” warning on save when “editor.codeActionsOnSave” setting contains “source.fixAll” value. Suggested value: true

    #9 Setting: Ignore ALPrefix & Ignore ALSuffix (AL Variable Helper)

    Remove prefix’s/suffix’s from variable names.

    This is the result when you create a variable with the AL Variable Helper. The prefix “CCO” is removed.

    #10 Setting: Enable Smart Commit

    Commit all changes when there are no staged changes. Suggested value: trueNote, danger, attention!!!: Read this blog post by Stefan Maron before enabling this. Stefan Maron suggests to disable Smart Commit, while I prefer to enable it. Either way, you should know what it does before you enable it. It will get you in trouble if you enable it without understanding it.

    #11 Setting: Autofetch

    When enabled, commits will automatically be fetched from the default remote of the current Git repository.Suggested value: true

    VS Code is able to periodically fetch changes from your remotes. This enables VS Code to show how many changes your local repository is ahead or behind the remote. Starting with VS Code 1.19, this feature is disabled by default and you can use the git.autofetchsetting to enable it.

    Read more about it here.

    #12 Setting: Background Code Analysis

    Specifies whether the code analysis should be performed in the background.Suggested value: small projects -> true, huge projects -> false

    Read more about it here.

    #13 Setting: Disable File Watcher On Change (AL Object Designer)

    This option prevents filewatcher to update object cache on every file change. Useful for BaseApp customization. Suggested value: small projects -> true, huge projects -> false

    I hope it helps you.

    If you can think of any other settings that definitely belong here, please let me know in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *