-
Notifications
You must be signed in to change notification settings - Fork 20
Visual Studio Code
On Fedora 35 and GNOME 41.4, VS Code's "Open File" Dialog (Ctrl + O) does not get focus, i.e. it falls behind the window (one has to Alt + Tab to get it). Interestingly, it works for the first time but from the second time on, it is out of focus.
The usual tricks (changing from Wayland to Xorg, reinstalling VS Code, settings its configuration to default, rebooting, tinkering window focus/auto-raise settings with the GNOME Tweak Tool and the dconf Editor, etc.) have no effect.
Alternative solutions include removing the VS Code installed from the official Fedora repository (sudo dnf remove code
). Then:
- Installing VS Code from an RPM gives the same result as installing it from the Fedora repository.
- Installing VS Code from Snap with
sudo snap install code --classic
solves the problem. However, file type associations have to be adjusted. On Fedora, this means editing~/.config/mimeapps.list
and performings/code.desktop/code_code.desktop/g
(make sure you don't end up withcode_code_code.desktop
entries!) - Installing VS Code from Flatpak solves the problem, however, it uses heavy sandboxing, so getting some extensions such as the LaTeX Workshop is tricky.
LaTeX Workshop is an extension to handle LaTeX documents.
See the documentation of LaTeX Workshop.
If you want, you can put a LaTeX docker image on your local machine and configure LaTeX Workshop to use that, eliminating the need of installing LaTeX. Tested on Windows+WSL2 (using remote wsl and remote container plugins), see documentation.
NOTE: If syntax highlighting does not work, change the color scheme.
If working in English use the Code Spell Checker
vs code extension. This extension does not support Hungarian, an alternative extension: Spell Right
. This uses the dictionaries of your operating system.
Recommended workspace settings for Spell Right
{
"spellright.language": [
"en",
"hu"
],
"spellright.documentTypes": [
"plaintext",
"markdown",
"latex"
]
}
Open the internal PDF preview by pressing Ctrl + Alt + V and selecting VSCode tab. Then, you can navigate between the code and the PDF with the following hotkeys:
- code to PDF preview: Ctrl + Alt + J
- PDF preview to code: Ctrl + click
Tables can be formatted using the latexindent
Perl scripts. It's recommended to test it in the command line and fix missing dependencies. On Ubuntu 18.04, these were sufficient:
sudo cpan Unicode::GCString
sudo cpan App::cpanminus
sudo cpan YAML::Tiny
sudo perl -MCPAN -e 'install "File::HomeDir"'
sudo cpan -fi Log::Log4perl #-fi might not be required?
sudo cpan Log::Dispatch
sudo cpan -fi File::HomeDir #-fi might not be required?
sudo cpan Log::Dispatch::File #?
On Fedora 32, this feature worked out-of-the-box with texlive-scheme-full
installed.
On macOS:
sudo cpan Unicode::GCString
sudo cpan App::cpanminus
sudo cpan YAML::Tiny
sudo perl -MCPAN -e 'install "File::HomeDir"'
See this issue for installation on other platforms.
To use the recipe instead set the following in settings.json
:
"latex-workshop.latex.build.forceRecipeUsage": true
-
Problem: When using the
latexmk
recipe, the build fails with the following message in the log (but there are no explicit errors in the Problems panel):bibtex: Not writing to /my/document.blg (openout_any = p). I couldn't open file name `/my/document.blg'
Meanwhile, building the document from the command line with
latexmk -pdf documentx.tex
works. -
Solution: Edit the TeX Live configuration file as suggested:
sudo vim /usr/share/texlive/texmf-dist/web2c/texmf.cnf
Change
openout_any = p
to
openout_any = a
To use XeLaTeX as the default build engine, set the following configuration in the settings.json
file:
"latex-workshop.latex.recipe.default": "latexmk (xelatex)"
Problem:
- Running the file using the play button stalls
- Using the "Run python file in terminal" command results in error "The active file is not a Python source file"
Solution: Go to Settings (Ctrl+,), and check whether the terminal is configured correctly. For me, the problem was caused by the "terminal.integrated.inheritEnv": false
setting. Interestingly, this setting if offered by the Python extension.
According to Stack Overflow, the terminal.integrated.shell.*
properties are also worth checking out.
- Problem: Changing tabs does not work with Ctrl + Page Up or Ctrl + Page Down.
- Solution: The problem was that I have left the Drop Down Terminal open in another window. Seriously.
Go to Settings (Ctrl+,), and set the Terminal | Integrated: Font Family key to e.g. Inconsolata-dz for Powerline
. Alternatively, add the following entry to the settings.json
file:
"terminal.integrated.fontFamily": "Inconsolata-dz for Powerline"
When word wrap (default: Alt + Z) is activated and typing, the horizontal scrolling moves a bit left and right. To fix this, the relevant Stack Overflow page has two answers:
-
one: the problem might be caused by GitLens, set the
gitlens.currentLine.scrollable
setting tofalse
. -
two: set the
editor.scrollBeyondLastColumn
value to0
(the default value is5
).
- advanced-new-file: Ctrl + Alt + N for a new file
- Unicode characters
You can configure VS Code such that it (re)attaches to a tmux
session when joining a remote server via SSH. This is useful for working on unstable connections.
"terminal.integrated.profiles.linux": {
"bash": null,
"tmux": {
"path": "bash",
"args": ["-c", "tmux new -ADs ${PWD##*/}"],
"icon": "terminal-tmux",
},
},
"terminal.integrated.defaultProfile.linux": "tmux",
Source: https://george.honeywood.org.uk/blog/vs-code-and-tmux/