how to rebind capslock to esc in vscodevim - json

I want to rebine the capslock key to esc in the vim on vscode.I configure my vim in the setting.json.
"vim.insertModeKeyBindings": [
{
"before": ["j", "j"],
"after": ["<Esc>"]
},
{
"before": ["capslock"],
"after" : ["<Esc>"]
}
],
I have tried the "capslock" ,<CapsLock>,<capslock>,"CapsLock"or "caps lock"and so on.But these all don't work.
THe solution : I use the hotkey software to rebind the key,i.e. change the keybinding in my whole computer

Related

use a different .zshrc for vscode internal terminal

I'm using zsh from vscode integrated terminal
i also use hyper terminal, warp and iterm2 for other purposes but i like to use the integreated terminal while in vscode. i actually enjoy my heavy .zshrc config on external terminals, but i often get the popup "your shell environment is taking too long to load" from vscode. Tbh, i don't mind the popup itself, but i think that a lot of the features that are useful outside vscode are not needed inside.
How can i set a different .zshrc to load only to be used by the vscode integreated terminal ?
tried conditional loading from my .zshrc but don't like it
tried setting it in the vscode-settings.json
this self-answer confused me more
this i think points in the right direction but i am not sure how to use task.json
my env:
macOS 13.1 22C65 arm64
Apple M1 Max
vscode (1.74.11ad8d514439d5077d2b0b7ee64d2ce82a9308e5a for arm64)
zsh 5.9 (arm-apple-darwin22.1.0)
These are the settings to change in “settings.json”:
I created 3 profiles:
zsh-minimal with the vscode minimal config -> new ZDOTDIR
zsh-full with my usual heavy config -> probably not necessary since it is $HOME by default i think
bash, just in case i fu everything
set to null old profiles ( zsh and zsh(2)) to delete them from profiles selection dropdown menu, as per official documentation.
“terminal.integrated.defaultProfile.osx”: “zsh-minimal”,
“terminal.integrated.profiles.osx”: {
"zsh-minimal": {
"title": "zsh-minimal",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiMagenta",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/.homesick/repos/MYUSERNAME-dotfiles/home/vscode_zsh"
},
},
"zsh-full": {
"title": "zsh-full",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiCyan",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/"
},
},
"bash": {
"title": "bash",
"path": "/bin/bash",
"icon": "terminal",
"color": "terminal.ansiWhite",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
},
"zsh": null,
"zsh (2)": null,
}

Need help editing "Preferences.sublime-settings - User"

Ok... I'm very new, so please be nice :)
I'm trying to change the cursor, but I don't know how to add the "cursor code" to the "theme code" (monokai pro). The "theme code" is below "cursor code", how do I use both successfully? All I want to do is change the cursor.
How do I add this code (cursor code)
{
"caret_extra_width": 5,
"caret_style": "solid",
"wide_caret": true
}
To this code (theme code)
{
"author": "Chris Kempson",
"color_scheme": "Packages/Theme - Monokai Pro/Monokai Pro.sublime-color-scheme",
"globals":
{
"background": "var(blue5)",
"caret": "var(white)",
"foreground": "var(white)",
"invisibles": "var(blue7)",
"line_highlight": "var(blue)",
"selection": "var(blue2)"
},
"ignored_packages":
[
"Vintage"
],
"name": "Tomorrow Night - Blue",
"rules":
[
{
"foreground": "var(grey)",
"name": "Comment",
"scope": "comment, string.quoted.double.block.python"
},
{
"foreground": "var(white)",
"name": "Foreground, Operator",
"scope": "keyword.operator.class, keyword.operator, constant.other, source.php.embedded.line"
},
{
"foreground": "var(red3)",
"name": "Variable, String Link, Regular Expression, Tag Name",
"scope": "variable, support.other.variable, string.other.link, string.regexp, entity.name.tag, entity.other.attribute-name, meta.tag, declaration.tag"
},
{
"foreground": "var(orange)",
"name": "Number, Constant, Function Argument, Tag Attribute, Embedded",
"scope": "constant.numeric, constant.language, support.constant, constant.character, variable.parameter, punctuation.section.embedded, keyword.other.unit"
},
{
"foreground": "var(orange2)",
"name": "Class, Support",
"scope": "entity.name.class, entity.name.type.class, support.type, support.class"
},
{
"foreground": "var(green)",
"name": "String, Symbols, Inherited Class, Markup Heading",
"scope": "string, constant.other.symbol, entity.other.inherited-class, markup.heading"
},
{
"foreground": "var(blue6)",
"name": "Operator, Misc",
"scope": "keyword.operator, constant.other.color"
},
{
"foreground": "var(white3)",
"name": "Function, Special Method, Block Level",
"scope": "entity.name.function, meta.function-call, support.function, keyword.other.special-method, meta.block-level"
},
{
"foreground": "var(white2)",
"name": "Keyword, Storage",
"scope": "keyword, storage, storage.type, entity.name.tag.css"
},
{
"background": "var(red2)",
"foreground": "var(white)",
"name": "Invalid",
"scope": "invalid"
},
{
"background": "var(white4)",
"foreground": "var(white)",
"name": "Separator",
"scope": "meta.separator"
},
{
"background": "var(white2)",
"foreground": "var(white)",
"name": "Deprecated",
"scope": "invalid.deprecated"
},
{
"foreground": "var(white)",
"name": "Diff foreground",
"scope": "markup.inserted.diff, markup.deleted.diff, meta.diff.header.to-file, meta.diff.header.from-file"
},
{
"foreground": "var(yellow)",
"name": "Diff insertion",
"scope": "markup.inserted.diff, meta.diff.header.to-file"
},
{
"foreground": "var(red)",
"name": "Diff deletion",
"scope": "markup.deleted.diff, meta.diff.header.from-file"
},
{
"background": "var(blue4)",
"foreground": "var(white)",
"name": "Diff header",
"scope": "meta.diff.header.from-file, meta.diff.header.to-file"
},
{
"font_style": "italic",
"foreground": "var(blue3)",
"name": "Diff range",
"scope": "meta.diff.range"
},
{
"foreground": "var(red4)",
"name": "diff.deleted",
"scope": "markup.deleted"
},
{
"foreground": "var(yellow2)",
"name": "diff.inserted",
"scope": "markup.inserted"
},
{
"foreground": "var(purple)",
"name": "diff.changed",
"scope": "markup.changed"
}
],
"theme": "Agila.sublime-theme",
"variables":
{
"blue": "#00346e",
"blue2": "#003f8e",
"blue3": "#3e999f",
"blue4": "#4271ae",
"blue5": "#002451",
"blue6": "#99ffff",
"blue7": "#404f7d",
"green": "#d1f1a9",
"grey": "#999999",
"orange": "#ffc58f",
"orange2": "#ffeead",
"purple": "#967efb",
"red": "#c82829",
"red2": "#f99da5",
"red3": "#ff9da4",
"red4": "#f92672",
"white": "#ffffff",
"white2": "#ebbbff",
"white3": "#bbdaff",
"white4": "#bbdafe",
"yellow": "#718c00",
"yellow2": "#a6e22e"
}
}
Without getting this error message:
Error trying to parse settings: Unexpected trailing characters in
Packages/User/Preferences.sublime-settings
Thank you guys!
What you are calling your "cursor code" is actually some preferences. They should be added to your user preferences (available via Preferences → Settings on the right side). Don't erase what's already there, just follow the rules of JSON - start with an opening curly brace { on one line, then have one preference per line with a comma , at the end of each line, then close with a curly brace }. You can have as many preferences set as you want, don't limit it to just those three. Look at the default preferences on the left for a list of every single one that's available. Don't worry if you don't understand what they all mean - you can customize just about every single thing about Sublime!
As far as the color scheme, which is kind of what your lower piece of code is - the easiest thing to do is to install Monokai Pro from Package Control and ignore that code completely - it's corrupted. If you haven't installed Package Control yet, install it by selecting Tools → Install Package Control…. Once that's done, hit CtrlShiftP on Windows/Linux, ⌘ShiftP on macOS, to open the Command Palette. Type in pci (short for Package Control: Install Package), hit Enter, type in monpro, select Theme - Monokai Pro, and hit Enter again. You may see a message on the status bar (down at the very bottom of the window) saying it's installing.
Once it installs, select Preferences → Color Scheme…, scroll through the list of options, click on Monokai Pro, hit Enter, and you should be good to go. I know it looks a little complicated, but in reality it's not. Once Package Control is installed, you don't have to install it again (in fact - you can't install it again). You should also learn through this exercise that all Sublime modal menus have fuzzy search, so you can usually just type a couple of letters and the option you want will pop right up.

Enter Input to sublime text

I am using sublime text 2 as the editor for my programs and using this code
{ "cmd": ["g++", "$file", "-o", "$file_base_name"],
"selector": "source.c++", "working_dir": "$file_path",
"variants": [ { "name": "Run", "cmd": ["g++", "$file", "-o", "$file_base_name", "&&", "$file_path/$file_base_name"], "shell": true } ]
}
I am able to run the c++ programs but unable to use test inputs in it.
How do I do that...
P.S. I don't wanna take inputs from any file but give to the console itself.

Adding Custom Menus in Sublime Text

How to add a custom Menu item in SublimeText 2 .
Any Ideas ??
I see there is a Main.sublime-menu file but dont know how to edit it.
Thanks!
The *.sublime-menu file is simply JSON. You can create a Main.sublime-menu in your user directory and it will be merged with other menu entries. It may be beneficial to look through the Main.sublime-menu files third party plugins have. These are generally much shorter, so may be easier to understand some of the things you need to define in each entry.
edit
You can use the following as a plugin to open notepad with an arbitrary file.
import sublime
import sublime_plugin
import subprocess
import threading
class OpenNotepadCommand(sublime_plugin.TextCommand):
def run(self, edit, filename=None):
th = NotepadThread(filename)
th.start()
class NotepadThread(threading.Thread):
def __init__(self, filename=None):
self.filename = filename
threading.Thread.__init__(self)
def run(self):
if self.filename is not None:
subprocess.call("notepad.exe %s" % self.filename)
else:
subprocess.call("notepad.exe")
When you are creating a menu item use something like the following for the command and arguments.
{
"command": "open_notepad",
"args": { "filename": "<the absolute path here>"}
}
Easier option if what you want is just run a command. Create a file Context.sublime-menu inside your Packages/User directory, and add the following:
[
{ "caption": "<Your caption here>", "command": "exec", "args": {"cmd": ["<your cmd name>", "<arg1>", "<arg2>", <...>]} }
]
Exemple: Adding a menu item to the context menu that just run dir:
[
{ "caption": "List files in current dir", "command": "exec", "args": {"cmd": ["dir"]} }
]
I know this way too late to join the party and add my 2 cents. Anyway, Main.sublime-menu is a file that allows you to add menu items to the top menu i.e [File, Edit, Selection, Find, View, Goto, etc.]
I recently added a new section "Dev" just to figure it out. I also wanted a way to trigger browser previews for a specific browser. Check it out.
[
{
"caption": "Dev",
"mnemonic": "Z",
"id": "dev",
"children": [
{
"caption" : "Previews",
"children": [
{ "caption": "Markdown Live Preview", "command": "new_markdown_live_preview", "id": "markdown_live_preview" },
{ "caption": "Preview in Default Browser", "command": "view_in_browser", "id": "markdown_live_preview" },
{ "caption": "Preview in Firefox", "command": "view_in_browser", "args": { "browser": "firefox" }, "id": "markdown_live_preview" },
{ "caption": "Preview in Chrome","command": "view_in_browser", "args": { "browser": "chrome" }, "id": "markdown_live_preview" },
{ "caption": "Preview in Safari", "command": "view_in_browser", "args": { "browser": "safari" }, "id": "markdown_live_preview" },
]
},
]
}
]
Anyway, this still works in ST3. Just in case anyone stumbles around here.

sublime in vintage mode - remapping escape failing

I'm trying to mapp jj to escape. I'm getting an error below. Fix?
I think you should place your configuration code in Default (OS).sublime-keymap, not in Preferences.sublime-settings.
You can find it in Sublime Text 2/Preferences/Key Bindings - User menu.
Open Sublime Text Keybindings Settings Default (Windows).sublime-keymap
Go to Preferences -> Key Bindings - User.
Inside your Default (OS).sublime-keymap file, add your remap..
[
{ "keys": ["j", "j"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
}
]