# Autocompletion for existing latex symbols

**URL:** <https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296>\
**Category:** VS Code\
**Tags:** question\
**Created:** [April 30, 2021, 9:21am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296 "2021-04-30T09:21:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)\
**Post date:** [April 30, 2021, 9:21am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/1 "2021-04-30T09:21:07Z")

</div>

Hello everyone,

I’m not sure, if this is the right category and if the system already exists but I would find it amazing if the Auto-Complete would also consider the latex name of symbol. For example, in case you have a code file containing latex symbols like

```julia
α = 2

```

then it would be super convenient, if you type ‘alpha’ it would recognize it as the symbol defined earlier.  
Does anyone know, if this is already possible with an add-on or does it require changes to the Julia language server? I think it would definitely be a nice feature that could save a lot of time and boost the usage of unicode-latex symbols.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [April 30, 2021, 9:40am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/2 "2021-04-30T09:40:13Z")

</div>

You get auto-complete of these symbols by using the `\` prefix, for example `\al + TAB` will propose `\aleph`, `\allequal`, `\alpha`. Writing `\alpha + TAB` will replace it with the Unicode symbol. See the [documentation](https://docs.julialang.org/en/v1/stdlib/REPL/#Tab-completion) for details.

Do you have something else in mind?

---

<div class="post-metadata">

**Author:** ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)\
**Post date:** [April 30, 2021, 10:20am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/3 "2021-04-30T10:20:32Z")

</div>

Yes, I’m referring to the autocomplete of the code editor for already defined symbols in the current scope. E.g. if I define something

```nohighlight
theta_0 = ...
θ₀ = ...

```

and I want to reference it some lines later. In VS-Code, if start typing `the`, it would show me `theta_0` in the autocompletion list but not `θ₀`. Even if I type `\the` it would not show me `θ₀`.

So, at the moment the only way to write `θ₀` is to retype `\theta TAB \zero TAB` all over again, every time that variable is used (or copy paste a lot). Therefore in my scripts I stopped using latex/unicode and switched back to `theta_0` because of the autocompletion. But I would love to switch back unicode, because I think it is such a nice idea to have it.

I guess this would require some changes to the Language Server of Julia (not sure about that though) so that `θ₀ ` is matched by the sequence `theta_zero` or `theta_0`.

How do you handle these problems? Does it work for others or in other editors?

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [April 30, 2021, 10:50am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/4 "2021-04-30T10:50:21Z")

</div>

Ah I see, yes that could be nice to have… Note that completion already works on Unicode symbols:

```julia
julia> θᵝ₃ = 2
2

julia> θ # Pressing TAB here will complete θᵝ₃

```

so what you’re asking is just to match `\theta` when the user completes `the` for example?

---

<div class="post-metadata">

**Author:** ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)\
**Post date:** [April 30, 2021, 11:00am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/5 "2021-04-30T11:00:40Z")

</div>

Oh thats nice, I didn’t know that this is possible. Does it also work in VS-Code (for me it only worked in the REPL)

Yes exactly. If have a defined variable name `θᵝ₃` and I type `theta` (or `the` or `thet` and so on) I would love to see the suggestion `θᵝ₃` in the autocomplete overlay. I’m not sure if it is possible at the moment.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [April 30, 2021, 11:45am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/6 "2021-04-30T11:45:32Z")

</div>

The unicode name should autocomplete fine when you have part of the identifier typed  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/e/5ed4a6f032864d74175413e3eddf8081571c7988.png)

It might be possible to trigger the same autocompletions when typing `theta`, I’ll look into that.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 30, 2021, 1:14pm UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/7 "2021-04-30T13:14:50Z")

</div>

Any change this could work in julia-vim? Another related improvement would be to be able to write, for instance

```julia
\theta^\beta_3 TAB

```

or

```julia
\theta_{123} TAB

```

to get `θᵝ₃` and `θ₁₂₃`

meaning, to have a more sophisticated latex-to-unicode translation. [This site](https://www.unicodeit.net/), for example, does that quite well, maybe it may provide some inspiration.

---

<div class="post-metadata">

**Author:** ![tqml](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tqml/32/22710_2.png) [@tqml](https://discourse.julialang.org/u/tqml)\
**Post date:** [April 30, 2021, 1:31pm UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/8 "2021-04-30T13:31:38Z")

</div>

Thanks!

Please let me know, if you find something. I’m fairly new to Julia but would love to learn more about it and also maybe helping implementing it (if it is a _new_ feature and others consider it useful too). However I wanted to ask here, if someone knows more about it before posting issues to the [vs-code extension](https://github.com/julia-vscode/julia-vscode) or [LanguageServer.jl](https://github.com/julia-vscode/LanguageServer.jl) repositories.

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [May 18, 2021, 6:42am UTC](https://discourse.julialang.org/t/autocompletion-for-existing-latex-symbols/60296/9 "2021-05-18T06:42:59Z")

</div>

This seems like a wanderfull feature. However, I do agree that you’ll still have to type the backslashes for the autocomplete to work. E.g, `the TAB` should not autocomplete, but `\th TAB` should.

I also agree that the latex-to-unicode could be more greedy, e g `\theta_\bet TAB` should autocomplete at once, even if \beta is not completely written.
