how to Suggestion acceptance only using enter and tab - visual-studio-code

I want to write normally in VSCode for newline, Want to type "e.keyCode" I try to type in new Javascript file only one char "e" and showing "else" suggestion, and when I type "." (dot), the "e" become "else"
In setting already done this.
"editor.suggest.showKeywords": false,
"editor.acceptSuggestionOnEnter": "on",
"editor.quickSuggestions": {
"other": "on",
"comments": "off",
"strings": "off"
}
Add setting for showKeywords and acceptSuggestionOnEnter.
The acceptSuggestionOnEnter is not working,
My question is how to accept suggestion only with enter and/or tab only.?
Thank you.

Related

VS Code Multiple Cursors - Paste Individual Lines Repeatedly

I am using VS Code with VI bindings and I am trying to do the following.
I have the following file contents:
abc="some value"
def="some other value"
ghi="some other other value"
jkl="some other other other value"
.
<etc. for many lines>
I want to make this file change to (Expected Output):
abc=${abc}
def=${def}
ghi=${ghi}
jkl=${jkl}
So far, I have first replaced =.+ with =${. I get the following:
abc=${
def=${
ghi=${
jkl=${
Then I am trying to use multiple cursors in VS Code by Cntrl + Alt + I and I am trying to copy each line from the beginning to paste it so that I get the expected output. For some reason, it isn't letting me select the whole line when I do a Cntrl + Home. Could someone please help me out with this?
For reference: The VI section of my settings.json file is as follows:
// my settings
"vim.easymotion": true,
"vim.sneak": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.handleKeys": {
"<C-a>": false,
"<C-f>": false,
"<C-w>" : false,
"<C-x>" : false,
"<C-c>" : false,
"<C-h>" : false,
"<C-b>" : false,
"<C-n>" : false
},
I don't use VI, but this is easy to do with a snippet (in your keybindings.json).
{
"key": "alt+b", // whatever keybinding you wish
"command": "editor.action.insertSnippet",
"args": {
"snippet": "${TM_SELECTED_TEXT/(.*)=.*/$1=${$1}/g}"
},
"when": "textInputFocus && editorHasSelection"
},
Then select your code and alt+b (or whatever keybinding you use). You don't need multiple cursors or need to select each line separately.
Why does it not work with Multi Cursor?
Using the default key bindings.
position cursor before a
use Ctrl+Alt+DownArrow as often as you like
use Shift+Ctrl+RightArrow select all before the =
Ctrl+C
RightArrow 2 times
Shift+End select all after the =
${
Ctrl+V
Esc
Or start selecting =" followed by
Ctrl+Shift+L LeftArrow Shift+Home Ctrl+X RightArrow Shift+End ${ Ctrl+V Home Ctrl+V Esc

In Visual Code (mac) is there a way to start at the second placeholder on a snippet?

I love to use snippets in the form of:
println("MyVariable:" + MyVariable);
So I end up creating snippets like this:
SnippetBody:[ "printlns(\"$1:\" + $1);" ]
The problem is that I want the focus on the second $1 so the intellisense triggers. Since the focus is on the first $1 and it's a string, then there is no intellisense.
Thanks!
If all you want is for autocomplete to work on strings, you can look at the settings and set:
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
}
Then you start typing and use CtrlSpace to trigger the list.

Sublime Text 3 macro to delete x lines from caret

I'm wanting to create a Sublime Text 3 macro to select 111 lines from the cursor and delete them. I tried recording this, but all it did was delete one character backwards, which I'm still confused by. I then looked into writing the macro manually, and the relevant commands here, but I've still not been able to figure out from that page whether what I want is possible, and if it is, how. Would really appreciate some help with this.
There is no internal Sublime Text command that will do multiple moves at once, unfortunately. However it is possible to define your own movement command via plugin code, which allows you to work around that.
To go this route, select Tools > Developer > New Plugin... from the menu and replace the default code with the following, then save the file as a python file (e.g. move_repeat.py). By using the menu entry to do this, Sublime will ensure that your plugin is stored in your User package.
import sublime
import sublime_plugin
class MoveRepeatCommand(sublime_plugin.TextCommand):
def run(self, edit, repeat=1, **kwargs):
for num in range(repeat):
self.view.run_command("move", kwargs)
This implements a new command named move_repeat which is a drop in replacement for the move command, providing an extra argument of repeat that specifies how many times to perform the movement that you provide.
As a drop in replacement, this can be used for any cursor movement (lines, words, etc).
Using this, your macro becomes the following:
[
{
"command": "move_repeat",
"args":
{
"by": "lines",
"extend": true,
"forward": true,
"repeat": 111
}
},
{
"command": "left_delete"
}
]
Here I just created the macro by hand-coding it. If you wanted to do this with an actual macro recording you would need to go about that another way.
For example, you could record the macro going down only one line and deleting, then manually add the extra value after the fact, or you could bind a key binding to the repeated command first and then do a macro recording.
The Messy Way
I've since managed to figure out a way to record macros. For some reason, the recorder doesn't register text selection by mouse, so I had to select the text via keyboard shortcut while recording the macro. This does the job in that it creates the macro I describe, although it also results in a script that I'm guessing is far less elegant than it would be if written by someone in the know.
Here's a shortened version of the script I ended up with:
[
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args":
{
"by": "lines",
"extend": true,
"forward": true
},
"command": "move"
},
{
"args": null,
"command": "left_delete"
}
]
It's as crude as it gets. It works by using the move command to select one line at a time. This means that this command block needs to be repeated for each line that you want to select for deletion. In my case, I needed 111 of them. Hopefully someone will come along and offer a nicer solution, but until then, this does the job.

How to get rid of annoying "newNode: node, offset: number" popup (intellisense?)

When editing javascript with Visual Studio Code I continuously get a useless and obtrusive popup showing some sort of irrelevant method signature
It also won't go away when typing. Even escape won't remove it but clicking in some other code usually does.
My current user config looks as follows
// Place your settings in this file to overwrite the default settings
{
"python.pythonPath": "/home/ivo/Atom/bin/python",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.unitTest.nosetestsEnabled": true,
"python.unitTest.nosetestPath": "bin/django",
"python.unitTest.nosetestArgs": ["test", "apps/"],
"python.unitTest.unittestEnabled": false,
"editor.acceptSuggestionOnEnter": false,
"editor.fontSize": 13,
"editor.renderControlCharacters": true,
"editor.useTabStops": false,
"editor.suggestOnTriggerCharacters": false,
"editor.wordBasedSuggestions": false,
"editor.quickSuggestions": false
}
To stop showing the annoying hint popups, open "settings.json" in VSCode:
(File -> Preferences -> Settings).
Add the following line to the setting file (including quotes), and save it:
"editor.parameterHints": false

Sublime Text autocomplete window closes when scrolling off the list

When scrolling the autocomplete list with up or down, if you go too far in either direction (e.g. there are no more suggestions), the list will close.
The behavior I want is to have the list wrap when reaching the end instead of close.
This is easy to fix with downward scrolling by assigning this hotkey:
{ "keys": ["down"], "command": "auto_complete", "context":
[ { "key": "auto_complete_visible" } ]
},
That's because the auto_complete command has built-in functionality to scroll downward each time it's invoked, which is why the hotkey works.
...But upward scrolling is different. I've tried about 20 different hotkey and macro combinations with no success.
I'm almost certain the only way to achieve this behavior is with a plugin, but unfortunately my Python skill level is nil.
If it matters, I'm manually invoking autocomplete with ctrl+space (the automatic popup is disabled).
I'm using Sublime Text 2.
Best solution: use auto_complete_cycle settings (added 26 March 2015):
Please use this new simple solution and not the python plugin
Sublime Text new version relased on 24 March 2015 has a new setting called auto_complete_cycle that implement this behaviour. Set it to true to iterate through the autocomplete results.
"auto_complete_cycle": true
Worst old solution: this custom plugin
I have just made this plugin that works well on Sublime Text 3 in Linux Mint. I have not tested it in Sublime Text 2 but think the plugin system it's the same, so, it should work on that version too. The workaround used it's not too pretty but works.
import sublime, sublime_plugin
class UpArrowInAutoCompleteCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.settings().set('autoCompleteFlag',True)
self.view.settings().set('initialPoint', self.view.sel()[0].begin())
""" Move one line up """
self.view.run_command('move', {"by": "lines", "forward": False});
""" Auto-complete was opened and up arrow was pressed, so if the cursor changes
(on_selection_modified will be triggered) we have gone outside the list.
If we were not in the first element on_selection_modified will not be triggered, so
we turn of the flag"""
sublime.set_timeout(lambda: self.view.settings().set('autoCompleteFlag', False),300)
class AutoCompleteSelectionModifiedTriggerCommand(sublime_plugin.EventListener):
def on_selection_modified(self, view):
if view.settings().get('autoCompleteFlag'):
""" If the up arrow was pressed and on_selection_modified
has been triggered, then we know that we were in the first element
of the list and we hitted the up arrow"""
view.settings().set('autoCompleteFlag', False)
initialPoint = view.settings().get('initialPoint')
""" We don't know how many words the auto_complete has, so,
in order to calculate that number, we move down in the list
till we get outside the list. After that we make the list appear
again and move down n-1 times to go (and stay) to the last line """
view.sel().clear()
view.sel().add(initialPoint)
view.run_command('auto_complete')
numLines = 0
while view.sel()[0].begin() == initialPoint:
view.run_command('move', {"by": "lines", "forward": True})
numLines += 1
if numLines == 401:
return
if numLines == 0:
return
view.sel().clear()
view.sel().add(initialPoint)
view.run_command('auto_complete')
numLine = 0
while numLine < (numLines-1):
view.run_command('move', {"by": "lines", "forward": True})
numLine += 1
To make the plugin use Tools>new Plugin and paste the code. Then save it in Packages/User folder. You can use Preferences>Browse Packages to find the Packages floder, inside which the User folder is located.
To make it work I added to my user key-bindings file this bindings (the second it's your own binding):
{
"keys": ["up"],
"command": "up_arrow_in_auto_complete",
"context": [{
"key": "auto_complete_visible",
"operator": "equal",
"operand": true
}]
}, {
"keys": ["down"],
"command": "auto_complete",
"context": [{
"key": "auto_complete_visible"
}]
}
Edit: this is an example result: