Vs Code Small Guide - dart

Whenever i write code in Dart in Vscode It shows me guide about stuff I don't want to see
How can I get rid if this annoying guide

These are called Parameter Hints (and are showing you the parameters for the function you're calling). You can disable them with this VS Code setting:

You can close quick suggestions by editing settings.json. To edit settings.json go to Preferences->Settings page (Shortcut: Cmd + Shift + P and type settings.json)
Then add the following code (or edit if there is 'editor.quickSuggestions' key in the file) to close quick suggestions.
"editor.quickSuggestions": {
"comments": false,
"other": true,
"strings": false
},

Related

Can't load ACE editor in a firefox addon, but can in chrome

I am using ACE editor in my browser extension. It all works fine in a Chrome/Chromium browser, but when I try the extension in Firefox (latest version), only ace.define and ace.require are available (ace.edit is needed, at least, to initialize).
Here is the part of the manifest (MV2) file involved:
"content_scripts" :
[
{
"matches": ["*://example.com/*"],
"all_frames": true,
"js": [
"ace-min/ace.js",
"myscript.js"
],
"run_at": "document_end"
},
]
What could be done wrong? Both files are being read, but only a part of ace.js seems to be executed. Imagine that myscript.js contains a console.log(ace), to see which functions can I use.
Thanks in advance!
I posted an issue on the ACE's GitHub repository. The response was very quick and polite.
All is explained in this comment: https://github.com/ajaxorg/ace/issues/4898#issuecomment-1217887526
Just a side note, use noconflict ace instead of normal ace. The function you need to change is at the bottom.

In Visual Studio Code Ctrl+V is not working

In Visual Studio Code Ctrl+V is not working on editor.
However from the command palette Ctrl+Shift+V is working.
I´ve had this problem when I enabled the "VIM" plugin for VSCode.
After uninstalling it, the problem was fixed.
Open the keyboard shortcuts preferences by pressing CTRL + SHIFT + P and search for open keyboard shortcuts file.
Then, search for the editor.action.clipboardPasteAction property. In your case, it might be CTRL+SHIFT+V. Try changing it to Ctrl + V. Like so:
Solution as of 2022
You could also CTRL + SHIFT + P and search for open keyboard shortcuts (JSON) and paste the following:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.sendSequence",
"when": "terminalFocus && !accessibilityModeEnabled && terminalShellType == 'pwsh'"
},
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear"
}
]
#WebD'is answer is very helpful and I have upvoted it. But my comment focused on whether there was a conflicting binding for CTRL-V and how to find it. You can literally type "Ctrl+V" (note the "plus+" sign, not a hyphen) and it will find all keybindings that use that binding in whole or part. I suggest that there must be a something else also bound to CTRL-V.
Since this original answer, vscode introduced another way to see what other commands might be bound to given keystrokes. With the Gear/Keyboard Shortcuts file open click on the little keyboardy icon to the right (or Alt+K with this file open) and it will indicate Recording Keys next to it. Now you can literally press Ctrl+V (or whichever keybinding you are interested in) and those corresponding commands, if any, that use that keybinding will be filtered up.
Remember to disable the Recording Keys functionality by clicking the keyboardy icon if you want to go back to regular searching in the Keyboard Shortcuts file.
I have the same problem: can't CTRL+X, CTRL+C, CTRL+V on VSCode editor.
I uninstall the Vim extension and the problem is fixed.
If you install the vim extension for visual studio code and find that ctrl + x, ctrl + v .. or other shortcuts stopped working, this is because they are overwritten by extension.vim_
If you prefer to get those shortcuts back go to keyboard shortcuts (ctrl + shift + p, then search for open keyboard shortcuts file).
Search for extension.vim_ and check too see if any shortcuts are
assigned to your key combination like ctrl + v. Remove it (right click, delete).
Also check for any other conflict by searching the file.
Save the file, it should work now.
For future searchers who do not have Vim (or any other extension) installed which is causing the issue, and who might have verified that their keyboard bindings are correct....
I have the Salesforce Extension Pack installed and had right-clicked on a file and run SFDX: Deploy Source to Org. The deployment had errors, so in the Panel area (which I have at the bottom of my screen) [see image] I had clicked on both the OUTPUT and PROBLEMS tabs, which shifted focus away from my PowerShell TERMINAL tab.
My Ctrl-V issue was when I was trying to correct my Apex code in the EDITOR pane. Ctrl-V was not pasting the code I had just Cut or Copied (but right-clicking and choosing Paste was working).
I ultimately discovered, when I changed my Panel focus back to my PowerShell TERMINAL tab, that ALL of the Ctrl-V pasting I had attempted had shown up after my PowerShell prompt! ["circled" in blue in image]
tl;dr
Make sure your pasted text did not show up in your TERMINAL - even if it is not in focus or even if your cursor is in another Panel tab or in the EDITOR.
From File > Performance > Keyboard Shortcuts > search paste > just try to remove or rest some keybinding with right click on paste or default:paste
If you have the Vim extension installed, you may set the vim.useSystemClipboard in the vim extension setting to true. Then you can paste the content from the clipboard by simply pressing p in the NORMAL mode, or use Ctrl+V in the INSERT mode.
This problem happened to me after I left VSC update itself (currently 1.53.0). It had been converted to Shift-Insert.
Go to File->Preferences->Keyboard shortcuts. Find the editor.action.clipboardPasteAction and double click it, then type Ctrl+V.
+1 for this - in case this helps anyone:
In my case it was only happening in the Thunder Client extension's text fields.
The culprit for me was the Indent on Paste extension (I'm on a Mac, so it was cmd+v instead of ctrl+v - but it fires the same event in VS Code).
I've left issue comments on the Thunder Client and Indent on Paste repos respectively, should anyone wish to add to those.
Look if and remove any VS Code extension :
for example - "Awesome Emacs Keymap" in my case, or any other keymaps installed.
i.e. : FILE/Preferences>/extensions and then look if any special keymap was installed
Modify the setting of vscode:
Settings - input:vim ctrl key - unselect: Enale some vim ctrl key commands that override otherwise common operations, like ctrl + c
go to extensions search Emacs keymap and uninstall it
There should something conflicting to your any previous keyboard shortcut
like in my case for Change All Occurrence: (Ctrl-C + Ctrl-A), vs code, confused with
Ctrl-C for a copy shortcut to this : (Ctrl-C + Ctrl-A), so I change this to (Shift-C + Shift-A), My Issue resolved.
Go to File>Preference>keyboard Shortcuts
Then Check for Copy and paste and enter the Ctrl+C and Ctrl+v shortcuts
Happy Coding ;)
None of the issues above solved this for me. I had a key binding Ctrl+C Ctrl+L. So when I pressed Ctrl+C it was in a state where it was waiting for the next key to be pressed and wouldn't do anything.
This showed up in the toolbar like so (an example):
This didn't come up in the list of keybindings when searching for Ctrl+C. So I found it be looking through the list.
Remove all cmd+v or in windows ctrl+v associated keybindings.
For me the solution was going through my extensions and disabling them one by one to find the culprit.
I had 'Paste and Indent' enabled which was messing up copying and pasting.
Just had to disable it and reload vs code.
Open Settings > keyboard shortcuts
Search for Ctrl + c
Delete the mapping for vim.
i have same problem
step:1
ctrl+shift+p
step:2 find
Open keyboard shortcuts
step:3
find paste
then you can see
editor.action.cliboardPasteAction
right click then changekeybinding if key wrong
or remove key if u found two same line(editor.action.cliboardPasteAction)
in my case is 2nd one(so i removed)
In some cases, if you use remote ssh connects to a remote server and code there, ctrl + V may not be useful because that your remote server has a high balance, you can try to uninstall some useless plugins in that remote server then reload vscode.
I have disabled all extensions, and VS Code hangs for a few seconds whenever I try to paste something. This occurs with Ctrl+V, Shift+Ins and also with right click + Paste.
It hangs, and then nothing happens.
[UPDATE]
I simply reinstalled it, and that solved the issue for me.
In my case just the relaunch of VSCode solved the issue. My key bindings were fine.
"Paste JSON as Code" was my offender, as well as a few other ones. I got a little extension happy there for a bit.
Its easy don't worry, you need to search using ctrl+shift+p and find Prefernces: Open Keyboard Shortcuts(JSON) and add this dict
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+c",
"command": "editor.action.clipboardCopyAction",
"when": "textInputFocus"
}
]
I thins it's very helpfull good luck :)

How to configure for inserting spaces instead of tabs on Visual Studio Code for Mac

I begin to use Visual Studio Code. Current version is 0.3.0.
By default, Indent is inserted for tabs.
But I want to insert 4 spaces instead tabs.
I can't find the configure out the item in Preferences.
Please tell me, how to configure insert tab or space.
Approximately since version 0.9.0 this configuration is easily reachable by modifying the following parameters in the settings.json file:
// Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened.
"editor.tabSize": 4,
// Controls if the editor will insert spaces for tabs. Accepted values: "auto", true, false. If set to "auto", the value will be guessed when a file is opened.
"editor.insertSpaces": true
For others settings and information visit the VS Code help section.
What you are looking for is in keybindings.json. From the menu Code -> Preferences -> Keyboard Shortcuts
On the right hand pane you can place your key bindings, for example:
{"key": "ctrl+t", "when": "editorTextFocus", "command": "editor.action.tab"}
though you would probably prefer something like:
{"key": "ctrl+t", "when": "editorTextFocus", "command": " "}
The problem is that it does not work as the documentation says it should!
See: Customization of Visual Studio Code
Microsoft has been notified of the behavior and tab handling preferences have also been requested.

How to add custom code snippets in VSCode?

Is it possible to add custom code snippets in Visual Studio Code? And if so, how? VSCode is based on Atom, so it should be possible.
Hit > shift + command + p and type snippets
Select Preferences: Configure User Snippets
Choose the language type for which you want to add the custom snippet in the vscode inputbox
vscode has comments to explain on how to add a snippet, as described on :> vsdoc or you can follow the next link with a short guide:
Lets say, we want to open custom snippets for the language GO. Then we can do:
Hit > command + p
Type: go.json + enter And you land on the custom snippet page
Snippets are defined in a JSON format and stored in a per-user (languageId).json file. For example, Markdown snippets go in a markdown.json file.
Using tools:
Snippet Generator extension (recommended)
Online snippet generator
Option 1 - Use the Snippet Generator extension.
It supports code to JSON conversion with optional scope support and space to \t conversion.
Demo:
Option 2 - Another extension is snippet-creator (deprecated).
After installing it, all you have to do is to :
Select the code that you want to make a snippet.
Right-click on it and select "Command Palette"(or Ctrl+Shift+P).
Write "Create Snippet".
Choose the type of files needed to be watched to trigger your snippet shortcut.
Choose a snippet shortcut.
Choose a snippet name.
Option 3 - check this website. you can generate snippets for vs code, sublime text, and atom.
Once snippet being generated on this site. Go to the respective IDE's snippet file and paste the same. For example for a JS snippet in VS code go to File->preference->user snippet then it opens javascript.json file then paste the snippet code from an above site inside this and we are good to go.
As of version 0.10.6 you can add custom snippets. Read the documentation on Creating your Own Snippets.
You can find/create custom snippets by placing the json file in C:\Users\<yourUserName>\AppData\Roaming\Code\User\snippets.
For example, a custom javascript snippets would be in a \snippets\javascript.json
You can also publish you snippets which is a really neat feature as well. John Papa created a nice angular + typescript snippet you can download as an extension in the marketplace.
Here is an example snippet taken for the documentation on a javascript for loop:
"For Loop": {
"prefix": "for",
"body": [
"for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {",
"\tvar ${element} = ${array}[${index}];",
"\t$0",
"}"
],
"description": "For Loop"
},
Where
For Loop is the snippet name
prefix defines a prefix used in the IntelliSense drop down. In this case for.
body is the snippet content.
Possible variables are:
$1, $2 for tab stops
${id} and ${id:label} and ${1:label} for variables
Variables with the same id are connected.
description is the description used in the
IntelliSense drop down
You can check out this video for a quick short tutorial
https://youtu.be/g1ouTcFxQSU
Go to File --> Preferences --> User Snippets. Select your preferred language.
Now type the following code to make a for loop snippet:
"Create for loop":{
"prefix": "for",
"body":[
"for(int i = 0; i < 10; i++)",
"{",
" //code goes here",
"}"
],
"description": "Creates a for loop"
}
You are done.
Type "for" in the editor and use the first prediction.
SHORTCUT
install snippet-creator extension (now deprecated).
Highlight the code that you need to make snippet.
press ctrl+shift+P and type "Create snippet" on the command palette and
press ENTER.
select language for which you want to create snippet(eg:-CPP), then type
snippet name, type snippet shortcut and then type snippet description.
You are now good to go.
Type the snippet shortcut in the editor that you entered in step 4, and select the prediction (if no prediction comes press ctrl+space) that comes first.
Hope this helps :)
Note: goto File->Preferences->User Snippets. Then select the language in which youcreated the snippet. You will find the snippet there.
You can add custom scripts, go to File --> Preferences --> User Snippets. Select your preferred language.
If you choose Javascript you can see default custom script for console.log(' '); like this:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
There's a VSCode Plugin called: snippet-creator (now deprecated).
After installing it , all you have to do is to:
Select the code that you want to make it a snippet.
Right click on it and select "Command Palette"(or Ctrl+Shift+P).
Write "Create Snippet".
Choose type of files needed to be watched to trigger your snippet shortcut.
Choose a snippet shortcut.
Choose a snippet name.
That's All.
Note : if you want to edit your snippets , you will find them in [fileType].json
Example : Ctrl+P , then select "javascript.json"
I tried by adding snippets in javascriptreact.json but it didn't worked for me.
I tried adding snippets into global scope, and it's working like charm.
FILE --> Preferences --> User snippets
here select New Global Snippets File, give name javascriptreact.code-snippets.
For other languages you can name like [your_longuage].code-snippets
This is an undocumented feature as of now but is coming soon. There is a folder you can add them to and they will appear, but it may change (its undocumented for a reason).
Best advice is to add this to the uservoice site and wait til its final. But it is coming.
On MacOS:
Open the VSCode
Code -> Preferences -> User Snippets
Search for "python" (or any language)
Write your snippet like this:
{
"Write pdb": {
"prefix": "pdb",
"body": [
"import pdb; pdb.set_trace()",
"$2"
],
"description": "Write pdb.set_trace() to debug Python scripts"
}
}
Save the file with command + S.
VSCode introduce this in version 0.5, see here.
Snippet syntax follows the TextMate snippet syntax and can write in User Preferences.
If you'd rather not deal with writing your snippets in JSON, check out Snipster. It lets you write snippets as you would write the code itself - not having to wrap each line in quotes, escape characters, add meta information, etc.
It also lets you write once, publish anywhere. So you can use your snippet in VS Code, Atom, and Sublime, plus more editors in the future.
This may not be a real answer (as some have answered above), but if you're interested in creating custom code snippets for other people, you can create extensions using yeoman and npm (which by default comes along with NodeJS) . NOTE: This is only for creating snippets for other's systems. But it also works for you too! Except you need JS code for whole thing.
You can add custom scripts, go to File --> Preferences --> User Snippets. Select your preferred language.
Like mine code is go, I do it as below:
"channel code": {
"prefix": "make_",
"body": [
"${1:variable} := make(chan ${2:type}, ${3:channel_length})",
"$4"
]
}
explanation: $1 will take your tabs & to give hints what are those tabs values, we make it like ${1:some_variable} which could give us hints what are those
I hope, it helps!

How do I setup/use ruby on rails snippets and autocomplete in sublime text 2?

I would appreciate if someone could direct me to a website that shows how to do this..
Can't seem to find anything decent enough via google.
This will be the first time I'm doing this kind of thing with a text editor.. It has got to the stage where typing out things like <%= %> is getting old and slow.
I've got a rails snippet package and also ryan-on-rails package installed. Just confused with how to start using them.
I'm on max osx - snow leopard
Kind regards
Update
This helped me out. http://webtempest.com/sublime-text-2-how-to-create-snippets/ but I still need a little practice.
I have a package "rails" can't remember where I got it but the triggering of snippets is working. I'd just like to find a nice list of the commands rather than have to go to each snippet and look for myself. I can find the by clicking on snippets but isn't there a way I can create a shortcut for that?
Also would like some auto indentation.. and also complete.
I'm puzzled that this isn't part of the default Rails package, but I found this to be just what I was looking for:
https://github.com/eddorre/SublimeERB
Since you're new to Sublime Text, I highly recommend you check out: ST2's Unofficial Documentation. If includes a ton of getting started info plus tons of info for extendibility and plugin development.
Another great "Getting Started" guide can be found here on Nettuts+.
If you're looking a list of your snippets and their associated shortcuts, go to "Tools > Snippets..." from your menu.
To expand <% into <%| %> (where | is the cursor), add the following you to your User-keybindings (Preferences > Keybindings - User):
{
"args": {
"contents": "% $0 %>"
},
"command": "insert_snippet",
"context": [
{
"key": "selector",
"match_all": true,
"operand": "source.ruby",
"operator": "equal"
},
{ "key": "preceding_text", "operator": "regex_match", "operand": ".*<", "match_all": true }
],
"keys": [
"%"
]
}
The latest beta includes improved auto-indentation, so if you don't have that installed, try that out.
As for autocompletion, Sublime Text 2 by default offers autocompletion of words in the current document (plus all of your snippets/completions from packages). However, if you're looking for IDE-like autocompletion, there is the SublimeCodeIntel plugin. I am reluctant to mention it because it has not been updated in months and the bug reports keep flowing in.
Hope that helps.
I use ERB Snippets
https://github.com/matthewrobertson/ERB-Sublime-Snippets
You can install via Sublime Package control
Cmd+Shift+P
Go to Package Control: Install Package.
Type ERB Snippets. Let it roll.
Then you can use tab autocomplete for lots of snippets such as:
print ERB tags = pe which auto completes to <%= %>
if block = if which auto completes to <% if %>...<% end %>
If you are looking for autocomplete suggest, change the auto_complete_selector in Preference like:
"auto_complete_selector": "text, source - comment",

Resources