Autocomplete for all text in current file

How can I turn on autocomplete to suggest for all text in the current file? The context/scoping for autocomplete isn't very smart :-/

7
17 comments

Haven't got what you mean, sorry... Would you like to limit the completion to variables/functions from current file only? or, would you like the completion to suggest all words you have typed in current file? In the latter case, did you try 'hippie completion' (cyclic expand word) - it's Alt+Slash in default keymap? See https://www.jetbrains.com/help/webstorm/2016.3/hippie-completion-expanding-words.html

6

Elena, he means something like the Default Autocomplete that comes with Notepad++: https://notepad-plus-plus.org/community/topic/13583/plugin-update-an-alternative-auto-completion-for-notepad .

This would be something that would trigger without needing to press any hotkeys, but wouldn't get inserted without pressing Enter or Tab.

In my opinion, this would be a VERY helpful addition.  AFAIK, there is no way to do this in IntelliJ.

2

Webstorm auto-completes code where appropriate - while typing variable, etc. names, after `.`, etc.

Showing auto-completion just on entering plain text would be rather annoying.

0

Elena, I don't think you understand the feature yet.  It is not annoying.  One of the world's most popular text editors has it.

Consider typing the following:

my_map = {
  'key' = 'value',
  'very_long_key_that_is_hard_to_type' = 'value_that_i_really_want'
}
# Note: often we get dicts from external data sources and we can't control the key names to make them short.

my_|desired = my_map['very|

In the above, the final line has two pipes (|).  These are the points at which the auto-complete would appear either with min_match=3 (for `my_|`) or min_match=4 (for `very|`.  I usually set my min_match to 3 in settings.

In the first case, you would get the option to select `my_map` by pressing enter or ignoring the autocomplete.  If your min_match was 4, you would not see an autocomplete option here at all.

In the second case, you would see `very_long_key_that_is_hard_to_type`.  That would be VERY useful.

1

This is something I too am desperately looking for.

The ability to have Ctrl-space suggestions on JSON keys and also inside any string.

There is so much JSON "navigation" that simply autocompleting on functions and variables is not enough.

The coolest thing would be if you could supply Webstorm some sample JSON structures and it could then use that for suggestions when you are typing e.g.

docJSON.modeli(ctrl-space) to suggest modelindicatorId

 

0

>The ability to have Ctrl-space suggestions on JSON keys and also inside any string

WebStorm provides JSON auto-completion based on  JSON Schemas. see https://www.jetbrains.com/help/webstorm/2019.3/json.html

0

The JSON Schemas support is only for editing an entire JSON files e.g. Settings.json

I am talking about when you are editing a Javascript (.js) file e.g.

function documentPrinter(documentArray) {   var i, curJSONDoc;
for(i=0; i<documentArray.length; i++) {
curJSONDoc = documentArray[i];
console.log(curJSONDoc.modelindiatorgloballyUniqueUuidIdentifer, ":", curJSONDoc.modelindicatordescriptionText);
}
}

When you are writing the console.log line it would be *very* helpful to be able to enter (ctrl-space) after having typed .modeli to and then select modelindiatorgloballyUniqueUuidIdentifer  from a list.

0

hardly possible with static code analysis - such completion would require executing a code

0

What I am suggesting requires neither static code ananlysis nor code execution.

I do not expect anything very "intelligent" from webstorm.

I the most basic case I would configure the project with a list of all possible JSON keys I would like to be completed.

When ctrl-space is pressed webstorm would simply list all list items where the characters after the "." are a leading substring.

I would *not* expect Webstorm to be able to decide precisely what keys would be legal at a given place in the code.

 

1

You can try using JSDoc for this, like:

 

/**
* @typedef {Object} MyJSON
* @property {string} modelindiatorgloballyUniqueUuidIdentifer
* @property {string} modelindicatordescriptionText
*
*/

/**
*
* @param {MyJSON[]}documentArray
*/
function documentPrinter(documentArray){}
0

I am using IntelliJ as a technical writing tool and would love to see something similar to Notepad++'s autocomplete tool for any text, not just JSON.

1

I can only suggest using 'hippie completion' (cyclic expand word) for this - it's Alt+Slash in default keymap

0

Hi there. I want to clarify do you have a solution for this request?

Thanks in advance.

0

Hello! Did anyone find a solution or workaround?

0

Did you try  'hippie completion' (cyclic expand word, Alt+Slash in default keymap) as suggested above?

-1

Hippie completion isn't what this post is about.

I did find a workaround though: VSCode has this feature.

I no longer use IntelliJ.

1

The hippie completion would be nice, as long as it will not cycle through the words and print them out rightaway. Otherwise, cycling through hundreds of words is a burden and thus the feature is useless.

I suggest to change the workflow to something like this:

  • Right after pressing Alt+/, a context menu (similar to Ctrl+Space) would be show with a list of all words used in the current file, ideally ordered by the most frequently used words.
  • Unless a Space/Enter is pressed, anything the user types would be considered as the search/filter string, thus only the matching words from the file will be listed.
  • The user can change the selected word using Up/Down arrows.
  • When a Space/Enter is pressed, the selected word would be actually inserted into the file. Alternatively, if a user want to exit the hippie completion without inserting a word, they can press Escape.

Elena Pogorelova, WDYT? Would that work for JetBrains?

---

Update

Or simply port the auto-suggestions feature from Fleet (see the screenshot below): it works as I wish it worked in WebStorm and how the OP wanted it to work and it works in Sublime Text and other text editors / IDEs.

0

Please sign in to leave a comment.