Open specific file using key when using vscode / vim - visual-studio-code

I often work in a specific file and would like to have that file opened when pressing a shortcut. I tried several combinations but seem to hit a wall..
// file settings.json
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["leader","t"],
"commands": [
"vscode.open"
],
"args": "notes/todo.md"
}
]
Any hint on how i can get this working? When executing the above code i get a illegal argument 'resource'

Using normal vim keywords solves the problem.
{
"before": [
"leader", "t"
],
"commands": [
":edit file:///notes/todo.md"
]
}

Related

How to map "Go To Implementation" using VsCode Vim?

I want to map something like gi to open a Typescript interface implementation for example. In VsCode the shortcut is Ctrl + F12 and I tried to add a map like this inoremap gi <C-F12> in .vimrc file but that does not work.
I also tried to do that in my settings.json but still no results.
"vim.insertModeKeyBindings": [
{
"before": ["g", "I"],
"after": ["<C-F12>"]
}
]
How can I do that?
You can achieve that by mapping a shortcut to a VSCode command, not a set of keys. If you look at VSCode shortcuts, you can see that the Go To Definition action is related to a command so you can take that command and map to a vim shortcut in your settings.json file.
In the example I will map gI to editor.action.goToImplementation which is the related command.
"vim.insertModeKeyBindings": [
{
"before": ["g", "I"],
"commands": ["editor.action.goToImplementation"]
}
],
"vim.normalModeKeyBindings": [
{
"before": ["g", "I"],
"commands": ["editor.action.goToImplementation"]
}
]

Hide search highlighting doesn't work VScode Vim

I'm starting to learn vim in VSCode and I have the following settings.json
{
"window.zoomLevel": 1,
"vim.insertModeKeyBindings": [
{
"before": [
"<C-c>"
],
"after": [
"<Esc>"
]
}
],
"vim.hlsearch": true,
"vim.normalModeKeyBindingsNonRecursive":[
{
"before":[
"<leader>",
"/"
],
"commands":[
":nohl"
]
},
{
"before":[
"<space>"
],
"after":[
"<leader>"
]
}
]
}
The problem is the ,/ part. It doesn't hide the highlighted search, it recognizes the leader key but after pressing /, the command :nohl is not executed.
I don't see what's wrong with the code, any help is appreciated.

How to make vim extension in visual code studio to use binding that repeats change for next match

How can I make vim extension in VSC make to use my keybinding?
In my .vimrc I got those lines:
" s* - CRTL + D like behavior
nnoremap <silent> s* :let #/='\<'.expand('<cword>').'\>'<CR>cgn
xnoremap <silent> s* "sy:let #/=#s<CR>cgn
How could I add them to my VSC?
Tried to add to my settings.json something like below, but got no idea how to add it properly every time I got an error:
Failed to handle key `*`: command '"sy:let #/=#s<CR>cgn' not found
"vim.normalModeKeyBindings": [
{
"before": [
"s",
"*"
],
"commands": [
":nohl:let #/='\\<'.expand('<cword>').'\\>'<CR>cgn",
],
"silent": true
},
{
"before": [
"s",
"*"
],
"commands": [
"\"sy:let #/=#s<CR>cgn",
],
"silent": true
},
]

How to cope with this error while compiling latex with vscode?

I followed several tutorials on the Internet and tried to build a latex environment in vscode. However, after I've installed everything and started running a .tex file, it came up with the following error:
Qt: Untested Windows version 6.2 detected!
xelatex: Bad parameter value.
xelatex: Data: font_mem_size
source code test.tex: (I put it in a folder on desktop)
\documentclass{article}
\begin{document}
Hello World!
\end{document}
I tried Google, but didn't find any effective approach. I also restarted my computer and reinstalled MiKTeX, but nothing changed.
By the way: I installed LaTeX workshop, MiKTeX and Strawberry Perl (just following the tutorial) and added this into the settings.json of vscode.
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
],
},
{
"name": "pdflatex",
"tools": [
"pdflatex"
]
},
{
"name": "xe->bib->xe->xe",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
},
{
"name": "pdf->bib->pdf->pdf",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.autoBuild.run": "onFileChange",
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
Update: the issue was solved by reinstalling MiKTeX and resetting its environment variables in PATH.
The issue was eventually solved by reinstalling MiKTeX and resetting its environment variables in PATH. (Another way is to directly install MiKTeX in its recommended directory, which is how I solved the problem.) In addition, the code I added in the settings.json should be discarded (or vscode will report errors).

Why is vscode vim.otherModesKeyBindingNonRecursive an unknown configuration?

I had this setting for couple of weeks now but it stopped working today. This is a setting for vscode vim easymotion. I dont know what happened. I havent change anything. Does anyone know why?
OS macOS high Sierra.
Vscode Version 1.24.1 (1.24.1).
Vscodevim v0.14.0 .
"vim.otherModesKeyBindingsNonRecursive": [
{
"before": [
"s"
],
"after": [
"leader",
"leader",
"s"
]
}
],
It looks like otherModesKeyBindingsNonRecursive has been replaced. See pull request 2726 on the VSCodeVim project. Instead see the current Key Remapping section in the project's README:
Custom remappings are defined on a per-mode basis.
"vim.insertModeKeyBindings"/"vim.normalModeKeyBindings"/"vim.visualModeKeyBindings"
Their example usage:
Bind : to show the command palette:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [":"],
"commands": [
{
"command": "workbench.action.showCommands",
}
]
}
]