Bounty: 50
As I type const someVariable = someArray[0]
, when I push enter, VSCode automatically converts the whole line to:
const someVariable = <someArray 0=""></someArray>
autocomplete
As I type const someVariable = someArray[0]
, when I push enter, VSCode automatically converts the whole line to:
const someVariable = <someArray 0=""></someArray>
I would like to find a program that suggests phrases that are commonly used by our business as the user starts typing them, similar to Gmail’s “Smart Compose” feature.
This could be an installed program that suggests phrases in any text input field (sort of like iOS’s keyboard, except for phrases instead of single words, and for MS Windows), or a web app where the person composes the report on a web page, then copies it to the appropriate place.
These questions are about predictive text for a single user, not for company-wide predictive text.
This question is about sharing formatting for reports, not about sharing phrases used in reports.
I have at the moment a completion function that looks something like this (except way more entries)
_arguments
'-check[do a check]'
'-play[play a specific song]:songnumber'
'-test.n=[run test specified number of times]:n'
'-test.dir=[run test in a specific working dir]:dir: _path_files -/'
'-test.v[run tests verbose]'
'-log[delete all log files]'
'*:inputfiles: _files'
upon tabbing this leads to printout like that:
pseyfert@robusta:~ > program -⇥
option:
-check -- do a check
-log -- delete all log files
-play -- play a specific song
-test.dir -- run test in a specific working dir
-test.n -- run test specified number of times
-test.v -- run tests verbose
One pattern is that a considerable number of options starts with -test.
and I am often not interested in them, so when looking for an option that I don’t know by heart, the entire -test.
block is somewhat spam. I’d prefer to group the options to a printout like that:
pseyfert@robusta:~ > program -⇥
option:
-check -- do a check
-log -- delete all log files
-play -- play a specific song
-test. -- test options
and then when reaching -test.
reveal what’s behind:
pseyfert@robusta:~ > program -test.⇥
option:
-test.dir -- run test in a specific working dir
-test.n -- run test specified number of times
-test.v -- run tests verbose
I realized I can get in the right direction with a minus after the option
_arguments
'-check[do a check]'
'-play[play a specific song]:songnumber'
'-log[delete all log files]'
'-test.-[test options]:testopts: _testopts'
'*:inputfiles: _files'
such that no space gets added after -test.
and a space will not be interpreted as “option continues”. What I lack in my repertoire is the _testopts
function. I’m tempted to use _arguments
again, but that requires leading -
after the -test.
. With _values
I am not aware of a method to place the descriptions and don’t know how to continue into other functions like _path_files -/
above.
Are there any examples for gradual option revealing or hints how to best change the design of my completion?
I am using zsh with oh-my-zsh on Ubuntu 18.04.2. Currently, Git is installed at version 2.20.1.
Whenever I want to push a local branch to a remote (origin
) I try to use the tab completion in the shell as follows:
git push origin fea<TAB>
The tab completion results in:
git push origin origin/feature
I cannot push to origin/feature
, though. What I actually want is:
git push origin feature
The same applies to git checkout
.
How can I configure the tab completion to correctly (?) complete the remote branch – or am I missing something?
I try to use the bash complete builtin to show different options for a command.
I have problems when an option contains a path like in -F/dev/null
.
Currently I’m using
#!/bin/bash
_xyz-completion ()
{
local cur
COMPREPLY=() # Array variable storing the possible completions.
cur=${COMP_WORDS[COMP_CWORD]}
case "$cur" in
-*)
COMPREPLY=( $( compgen -W "-oOption1 -F/dev/null" -- $cur ) )
;;
esac
return 0
}
complete -F _xyz-completion -o filenames xyz
If -F
was already typed, then a Tab completes it successfully.
But if only -
was typed, then a Tab shows
null -oOption1
But I expect to see
-F/dev/null -oOption1
I tried already -F/dev/null
, -F//dev//null
, "-F/dev/null"
and -F\/dev\/null
It seems to be only a display problem, as the completion itself works as expected.
To comment the comments:
1)
Never mind, it’s a problem also if -F is replaced by a non-option such as -Q. – Benjamin W.
It’s not a problem, that the -F
looks like a option for complete
itself, as it even fails if I changed it to xOPTION1 xF/dev/null
2)
I’m wondering what compgen -W “-oOption1 -F/dev/null” — – displays for you.
It displays (as expected)
-oOption1
-F/dev/null
As mentioned, -F
completes successfully to -F/dev/null
If you’re on chrome, you can view your autocomplete predictions in chrome://predictors/
.
However, there doesn’t seem to be a way to modify them.
How can you add, edit, or remove your predictors on chrome?
I’m a fan of Sublime Text 3 and would like to get code autocompletion for PyTorch. However, I can’t get this working yet. Any suggestions or starting points where I can begin to get this working?
I have searched in the packages repository of Sublime Text but unfortunately there’s none.
Note: I have looked at a related question here IDE autocomplete for pytorch but that’s only for VS Code.