Hide search highlighting doesn't work VScode Vim - visual-studio-code

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.

Related

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 inject a TextMate grammar to a Markdown heading in VS Code?

I want to select [ ] for syntax highlighting within a markdown file in VS Code.
I can target [ ] using the following regex: (?<=\s)\]|\[(?=\s).
However [ ] doesn't get matched when it is part of a heading.
As a minimal example, in the package.json I have the following:
"contributes": {
"grammars": [
{
"scopeName": "markdown.todo",
"path": "./syntaxes/todo.markdown.json",
"injectTo": ["text.html.markdown"]
}
]
}
Then, in the todo.markdown.json I have:
{
"scopeName": "markdown.todo",
"injectionSelector": "L:text.html.markdown",
"patterns": [
{ "include": "#item-todo" }
],
"repository": {
"item-todo": {
"name": "item.todo",
"match": "(?<=\\s)\\]|\\[(?=\\s)"
}
}
}
Finally, in the VS Code settings.json I apply a color using:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "item.todo",
"settings": {
"foreground": "#FF0000"
}
}
]
}
I can see below that [ ] gets selected, but not when it is within a heading.
When I inspect the tokens and scopes I see several textmate scopes.
I am not sure if this is related, but it seems that VS Code is highlighting the markdown headings based on the markup.heading scope. However, markup.heading is not present in the textmate scopes array.
I tried changing to "injectionSelector": "L:heading.1.markdown" and/ or "injectTo": ["heading.1.markdown"], but no matter what selectors I specify I cannot seem to be able to match [ ] within a heading.

How do I rebind Y to yank to the end of the line when using VS Code's Vim extension?

I'm using VS Code's neovim integration with neovim installed from snap. I want Y to work the same way as D and C. In ~/.config/nvim/init.vim I would add
map Y y$
How do I do this in VS Code? I've tried
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["Y"],
"after": ["y$"]
},
],
and
"vim.normalModeKeyBindings": [
{
"before": ["Y"],
"after": ["y$"]
}
],
but neither worked.
Turns out you need to specify and separate each key into an individual "", so that would be:
"vim.normalModeKeyBindings": [
{
"before": ["Y"],
"after": ["y", "$"]
}
]

Remap ':w' in VScode Vim

I'm trying to remap ':w' to 'zz' in vscode vim. I've made 2 attempts, (one commented out). So far its not working. How can I perform this remap?
"vim.commandLineModeKeyBindings": [
{
"before": [":","w"],
"after": ["z", "z"]
// "before": ["z", "z"],
// "after": [":","w"]
},
]
You should be able to use the following to map zz to the save action:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["z", "z"],
"commands": [
":w"
]
}
]

Open specific file using key when using vscode / vim

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"
]
}