Indenting multilines/block with vscode and vim plugin - vim

This is already on the site, but it doesn't work for me. I'm not 100% sure the answer is responsive to my situation (the question asks about vim "mode"). If it is, the context for the accepted answer isn't obvious for me.
I assume were supposed to splice the json fragment
{
"key": "shift+tab",
"command": "outdent",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}
into our settings but it's not clear how or where. The app has a settings.json, a keybindings.json and the plugin has package.json.
I got this to work in vim itself a year or so ago IIRC, but it took a plugin and a couple of settings.
Edit to add: ctrl+[ and ctrl+] aren't functional for me. Presumably they would be w/o the vim plugin, but the plugin overrides the ctrl commands.

Just as in normal vim, typing >> and << in normal mode or > and < in visual mode will indent and un-indent lines, respectively.
Source: https://vim.fandom.com/wiki/Shifting_blocks_visually
Also: https://stackoverflow.com/a/235841/7007605

If you are using the main Vim (VSCodeVim), the standard m>, m<, :m,n>, :m,n< are not supported (see https://github.com/VSCodeVim/Vim/issues/3733).
However, this feature is supported by the Neo Vim VS Extension (asvetliakov.vscode-neovim). Note that if you go this route, you do need to install neovim (>v0.5.0) separately, which you can obtain at https://github.com/neovim/neovim/releases/nightly. Then set the path to the neovim executable/binary in the Neo Vim VS extension settings.

I remaped < and > in normal mode to ident lines while using the VSCode commands:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<"],
"commands" : ["tab"]
},
{
"before": [">"],
"commands" : ["outdent"]
}
]

Related

Ignore flake8 warning in SublimeLinter

I have installed SublimeLinter-flake8. I would like to exclude the W191 warning when I am using SublimeLinter with flake8. I have checked the SublimeLinter docs and tried adding "--ignore W191" to my user settings file and reloaded plugins but I still get warned about the usage of tabs.
The following is my Packages/User/SublimeLinter.sublime-settings file.
// SublimeLinter Settings - User
{
"linters": {
"linter_name" : {
"args" : "--ignore W191"
}
}
}
I checked this answer on StackOverflow but I would like it to be applied from the settings file.
The linter_name has to be the specific plugin you're looking to configure (in this case flake8) -- try this:
{
"linters": {
"flake8" : {
"args" : "--ignore W191"
}
}
}
though realistically, it is probably better to configure your flake8 settings in flake8's configuration such that contributors to your project can work on your project without your specific sublimetext settings. I believe sublimetext's invocation of flake8 should be compatible with those configurations if I'm reading their code correctly
disclaimer: though I'm not sure it's super relevant here, I currently maintain flake8

Autoformatting failed, buffer not changed : Sublime text

While setting up Python Development Environment in Sublime text 3, I wanted Auto formatting on and hence I made the following settings in Preferences > Package settings > Anaconda > Settings User
{
"auto_formatting": true,
"autoformat_ignore":
[
],
"pep8_ignore":
[
"E501"
],
"anaconda_linter_underlines": false,
"anaconda_linter_mark_style": "none",
"display_signatures": false,
"disable_anaconda_completion": true,
"python_interpreter": "/usr/local/bin/python3"
}
The auto_formatting value is set to true in user settings and it is set to false in default settings .
The auto formatting does not work out and gives me Autoformatting failed, buffer not changed error . Also tried changing auto_formatting_timeout = 5 //seconds , but that didn't work out . It would be of great help if someone could help me out .
I had the exact same issue. The problem is the last line is pointing to the wrong path for your python interpreter
Preferences > Package Settings > Anaconda > Settings - User
Delete the last line
"python_interpreter": "/usr/local/bin/python3"
Replace it with
"python_interpreter": "C:\\Users\\YOUR_NAME\\AppData\\Local\\Programs\\Python\\Python38-32\\python.EXE"
IMPORTANT: Your python interpreter path might be different to mine so find out where it is. Remember you need to use TWO backslashes in the path not ONE
Sublime is looking for python in environmental variable when you build it, and it is not able to find it there. You can test it in cmd by typing python and if it opens Microsoft store then here is the fix you can do, it worked for me. Open setting -> search for manage app execution aliases -> turn off "python.exe" and "python3.exe". Now check if you can get python in cmd by typing python, if you do then sublime problem should be fixed. If you want to know why this works follow this stack overflow

How to set clang-format options in local vimrc (.lvimrc) file?

I am using Local vimrc for project specific vim settings. I have the .lvimrc file in my project directory with specific settings as shown below and it works.
set tabstop=2
set shiftwidth=2
set softtabstop=2
But, I am unable to override the clang-format settings, for e.g when I run :ClangFormat, vim still uses the settings present in .vimrc file in my home folder
I have the following clang-format setting inside the .lvimrc file.
let g:clang_format#style_options = {
\ "Language": "Cpp",
\ "IndentWidth": 2,
}
Local vimrcs should define local options with setlocal, and let b:option_name = value.
Unfortunately not all plugins understand that some users can work on several projects simultaneously. In that case, you need your local vimrc plugin to always load local vimrc files every time you enter a buffer (even if it was already opened). And then you can protect the buffer local definitions to be (re)set again.
I can not speak for the plugin you're using. Mine reloads vimrc_local.vim files everytime we BufEnter a buffer. As a consequence the local vimrc file looks like
" -- Global Overridden zone for project unaware plugins
let g:some_global_option_overwritten_every_time = "forced value"
" -- Buffer local zone for project-aware plugins
if exists('b:project_foo_bar_lvimrc_loaded') && b:project_foo_bar_lvimrc_loaded != 0
finish
endif
let b:project_foo_bar_lvimrc_loaded = 1
setlocal whatever=value
let b:some_option_for_a_smart_plugin = "specific value"
" -- and we can also add a global zone for stuff that we can load once
" like functions, but it'll be smarter to use autoload plugins
BTW, reading the plugin documentation, it looks like it also listen BufEnter, and unlike my plugin it seems to automatically set guards. One other possibility is that your project is in a blacklisted directory tree. You'll have to check that also.

Sublime Text 3 on Ubuntu: custom keybinds in packages

Problem
My problem is that the custom keybindings that I assign in Sublime Text 3 on Ubuntu are not registered. In my case, I am trying to set them for commands in the 'MarkdownPreview' package.
Setup
I have the following setup:
Ubuntu 16.04
Sublime Text 3 (build 3126)
MarkdownPreview package
Details
My MarkdownPreview.sublime-settings looks as follows (User settings):
[
{"keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"}},
{"enable_mathjax": true}
]
I have already opened the console and set sublime.log_input(True) and sublime.log_commands(True).
The output in the console when pressing alt+m does show the event being registered, but no command is trigged. See this console excerpt:
key evt: backspace
command: left_delete
key evt: alt+m
key evt: control+c
command: copy
I can run the command from the command palette and the "enable_mathjax": true setting works fine
The reason this doesn't work for you is that you've put the key binding in the preferences for the package instead of in the key binding file, where Sublime can't see it.
The mathjax setting you have should be in your MarkdownPrevious.sublime-settings file, as that's a setting for the package. So that file should look like this:
{
/*
Enable or not mathjax support.
*/
"enable_mathjax": true
}
With that done, you want to select Preferences > Key Bindings (or if you're using an older version of sublime, Preferences > Key Bindings - User) and put your key binding in that file:
[
{
"keys": ["alt+m"], "command": "markdown_preview",
"args": {
"target": "browser",
"parser":"markdown"
}
},
]
This shows the complete contents of the key bindings file with only this single key binding. If you have any other custom key bindings, add this to your file without the [ and ] surrounding it (as they will already be in the file).

stop checking for updates

In sublime terminal (ctrl + `) every minute I got annoing lines:
Checking for updates:
Sync Enabled: True
Sync Timeout: 60000
Latest Update at: Thu Jan 1 00:00:00 1970
Thread is: Thread-4
Paths: [{'path': '', 'display': ''}]
It interrupt me from debuging sublime plugins.
How to disable this Checking for updates?
I tried 2 things to disable it:
I added line "update_check": false into /Users/maks/Library/Application Support/Sublime Text 3/Packages/User/Preferences.sublime-settings:
{
"ignored_packages":
[
"JavaScript Console",
"Vintage"
],
"update_check": false
}
And restarted sublime. But nothing...
I tried to find string 60000 in all files of sublime folder: /Users/maks/Library/Application Support/Sublime Text 3
But nothing good found. Maybe 60000 ms is default value.
Update
Created function to search text in packages and installed packages:
searchInSubl()
{
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages; zgrep -e $1 *.sublime-package ; cd ../Packages; grep -R -e $1 *
}
With help of it I searched by different words: "Checking for updates", "Sync Enabled", "Sync Timeout", "60000", "Latest Update at", "Thread is", "Paths". But nothing found.
Seemingly this update is internal sublime 3 option. Don't know how to disable it...
My current version of sublime text 3 is 3083. Here how the guys solved it HERE.
Text version
Go to Preferences -> Settings-User -> and paste that line of code in the end:
"update_check": false, or "update_check": false (without last comma if it's last item in the array). After that press CTRL + S (on Windows OS) to Save file or go to File -> Save
Image version
Since Sublime Text 3 packages are in zipped .sublime-package files, you'll need to use zgrep to search them:
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages
zgrep -e "Checking for updates" *.sublime-package
If nothing is found, try looking in the Packages directory:
cd ../Packages
grep -R -e "Checking for updates" *
Hopefully one of these will match a package. If so, add the package to your ignored_packages setting and restart Sublime.
If neither search works, try using other fragments of the message as your search term: "Sync Enabled", "Latest Update", etc.
Good luck!
Please Note:
This is not the same issue as this one, where setting "update_check": false in your user preferences does not stop Sublime Text 3 from displaying upgrade messages when a new build is released. This particular issue was caused by a plugin constantly printing a message to Sublime's console. As the OP commented below:
using turning off and on every single plugin, target plugin found, its name: "My Snippets" in Installed Packages folder.
Two solutions, depending on what exactly you want to accomplish.
Since I am not sure - possibly my English - so I give you two solutions.
BLOCK PACKAGE FROM UPDATING
I use Sublinter as an example.
Preferences > Package Settings > Package Control > Settings – User
... and add something like this to block package:
// Packages to not auto upgrade
"auto_upgrade_ignore": [
"SublimeLinter"
],
BLOCK SUBLIME FROM UPDATING
If you want Sublime to stop updating and you do not trust in-app update blocking solutions, just nuke 'em.
On Windows (system I use) go to:
C:\Windows\System32\drivers\etc
... and open file named 'hosts'.
You may have to move this file onto desktop, edit it and move it back to original location, as Windows may not allow any changes to it - even, if you try as Administrator.
Then add to 'hosts' file this line of code:
127.0.0.1 localhost www.sublimetext.com
127.0.0.1 localhost sublimetext.com
Version with 'www' will do, as sublime sends updates from 'www.sublimetext.com' location.
Above code will prevent any connection from your machine to 'www.sublimetext.com', hence no updates anymore.
That does not apply to packages, they need option #1.

Resources