How to disable sublime text 4 Context-Aware Suggestions - sublimetext

In sublime text 4, it will suggest context word, I want disable that feature.
for example, I type wh, I will get a "while snippet".
when file have "while" word, I type wh,I will get "while" word and "while snippet",I have to move down to select "while snippet".
"auto_complete_use_index": false, do not work.
Is there a way to disable the first "while" word.

If you don't want to inhibit word/buffer completions entirely, you can create a plugin like the following (Tools menu -> Developer -> New Plugin... and replace the placeholder with the following):
import sublime, sublime_plugin
class InhibitWordCompletionsEventListener(sublime_plugin.EventListener):
def on_query_completions(self, view, prefix, locations):
return sublime.CompletionList([sublime.CompletionItem.command_completion('', 'noop')], sublime.INHIBIT_WORD_COMPLETIONS)
Be sure to save it in the folder ST recommends (i.e. Packages/User/) with a .py extension.
Then, when you type wh, ST won't suggest the word while, just the Python snippet.
NOTE: this feels like a bit of a hack, it may not work this way in future builds of ST, but I tested on 4125 and it works there.
If you do want to disable buffer completions entirely, see How to remove words in the current buffer from Sublime Text 4 autocomplete list.

On my test for version 4121,I get the following results:
"auto_complete_include_snippets": false, --OK
"auto_complete_use_index": false, -- no work
"index_files": false, -- no work
Given this, you can try the setting:
"auto_complete_include_snippets"

Related

Snippets where content is conditional on language in Sublime Text 3?

Is there a way to create a single snippet file where the content output is dependent on the language? For example, keyboard shortcut x outputs "abc" when used in a css file, but "def" when used in a javascript file?
Snippets don't contain much processing capability — you can perform substitutions in them via Boost-style regexes and format strings, and they have access to a number of environment variables within Sublime such as the current file's name, the line number, etc., but beyond that they don't have much programmatic processing capability. It might be possible to set up a series of regexes that try to case-insensitively match $TM_FILENAME against \.css$ and output abc, then immediately match $TM_FILENAME against \.js$ and output def - only one of them will be successful.
However, in my mind such processing is much more easily handled by a plugin written in Python. The API documentation is mostly complete (all the functions you'll need are documented there) and there are a ton of examples around the net to learn/borrow from. Here's a quick example:
import sublime_plugin
class PrintScopeCommand(sublime_plugin.TextCommand):
def run(self, edit):
pos = self.view.sel()[0].begin()
scope = self.view.scope_name(pos)
if 'source.js' in scope:
self.view.insert(edit, pos, "This is JavaScript!")
elif 'source.css' in scope:
self.view.insert(edit, pos, "This is CSS!")
Save the file in your Packages/User directory (accessible via Preferences -> Browse Packages...) as print_scope.py. Next, assign it to a key binding by opening your user keymap (Preferences -> Key Bindings-User) and adding the following:
[
{ "keys": ["ctrl+alt+shift+p"], "command": "print_scope" }
]
if the file is empty. If you already have other custom key bindings, just add a comma , after the last one, then paste the line above after it, before the closing square bracket ].
You should now be able to hit CtrlAltShiftP (or whatever other key binding you choose), and if the file's syntax is set to JavaScript it will insert the This is JavaScript! message at the current cursor position. If the syntax is set to CSS, This is CSS! will print, and if the syntax is anything else, then nothing will print.

Sublime Text on OSX: Spell checker does not learn

I'm trying to get the/a spell checker working for ST2 on OSX (10.6.8 and 10.8.5). The build-in solution does a pretty good job, especially for LaTeX files. I do see words underlined in red, if ST2 thinks they contain a typo. But if I choose to "ignore" these words (no more highlighting then) and restart Sublime Text, they're highlighted again (same thing happens with ST3).
I'm not even able to find the list of ignored words and I somehow get the impression that ST seems to "forget" those words. I've tried to add a list manually in my Preference.sublime-settings file: no effect.
The "CheckBounce" plugin looks like a promising alternative, although LaTeX support is missing (most commands are highlighted as incorrect).
Any ideas?
See the section for ignored_words below. You need to manually add words to your preferences file. I've set the preferences files to hot-keys to have easy access.
/Users/HOME/Library/Application Support/Sublime Text 2/Packages/User/Preferences.sublime-settings
{
"auto_complete_triggers":
[
{
"characters": "./\\()\"'-:,.;<>~!##$%^&*|+=[]{}`~?",
"selector": "text.shtml"
}
],
"color_scheme": "Packages/User/lawlist.tmTheme",
"find_selected_text": false,
"font_face": "Courier",
"font_size": 18.0,
"forward_sync": true,
"ignored_packages":
[
"Vintage"
],
"ignored_words":
[
"Joinder",
"\\bf\\uline",
"\\begin{singlespace*}",
"\\end{singlespace*}",
"\\begin{tightcenter}",
"\\end{tightcenter}",
"\\begin{document}",
"\\end{document}",
"quotingsetup",
"renewenvironment",
"doublespace",
"flushright",
"minipage",
"pagestyle",
"uuline",
"textbf"
],
"inverse_cursor_state": true,
"keep_focus": false,
"scroll_past_end": true,
"show_full_path": true,
"word_separators": "./\\()\"'-:,.;<>~!##$%^&*|+=[]{}`~?"
}
It seems like the ignore_word command in your sublime does not add the word to the ignored_words list. I am currently using ST3 and it has the same problem. So I made a small plugin to make the context command ignore xxxxx adds a word to the ignored_words list in your user's preferences.sublime-settings.
Here is the repository: https://github.com/zcold/ignore_words
If you are using package control, just add a new repository and install the plugin named ignore_words.
If you do not use package control, just create a ignore_words folder in ${sublime}\data\packages\ and copy the file ignoreword.py from the mentioned repository into that folder.
I hope it solves your problem.
One way to solve this, is add the word by hand to the dictionary.
Locate the .dic file, in there you will see a big list of words with the follow format word/p [CAT=,G=,N=]
Those things after the word are features of the word (e.g proper name ,feminine,...)
Find a similar word and copy that part to your entry.
Save the file, restart your editor (to reload the dictionary) and you should be good to go :)

Is there a way to fold all multi-line Ruby comments in Vim?

I'm working on a Ruby gem and I would love to be able to hide all the documentation comments in the file because they are more for people using the library than reading or writing the code. I see the value in having the comments, but when I'm working on the code they are visually distracting to me.
In MacVim I can manually fold lines of code by selecting them and clicking Tools > Folding > Create Fold, but is there a way to automatically hide all comments using some sort of shortcut?
For example, the following code:
# Returns a 2D array for Rails select helper options.
# Also used internally for Formtastic support
#
# ==== Example
# # Create an Enum with some elements
# class Priority < ClassyEnum::Base
# end
#
# class Priority::Low < Priority; end
# class Priority::ReallyHigh < Priority; end
#
# Priority.select_options # => [["Low", "low"], ["Really High", "really_high"]]
def select_options
map {|e| [e.text, e.to_s] }
end
would be displayed as:
def select_options
map {|e| [e.text, e.to_s] }
end
You could try this method:
:set fdm=expr
:set fde=getline(v:lnum)=~'^\\s#'?1:getline(prevnonblank(v:lnum))=~'^\\s#'?1:getline(nextnonblank(v:lnum))=~'^\\s*#'?1:0
The problem is that this method would become the only folding option so that's probably a little bit extreme.
I guess you would like to play with vim’s foldmethod setting. Sorry for slightly vague answer, but I have no MacVim here so you are supposed to adjust directories/filenames in my suggestion yourself.
First of all, try :setlocal foldmethod=syntax in command mode to enable folding within your current file only. If it works, you have all the prerequisites installed (namely, the ruby.vim syntax file.) Try to add let ruby_fold=1 to your .vimrc file. The latter should enable folding over all ruby files (or, alternatively you may explicetely set folding to true for all filetypes supporting folding with set foldmethod=syntax.)
Now you are to find ruby.vim over your file system to tune it up. To give a hint, on Linux distros it’s located at /usr/share/vim/vim73/syntax/ruby.vim. My syntax file enables folding for all the stuff which “may” be folded (e. g. functions, methods, etc.) Copy the original file to your $HOME/.vim/syntax directory and adjust it according to your needs. Navigate through it (by searching for fold, for instance) and remove fold keyword where you don’t want the folding is applied. The names in syntax file are self-explanatory, so you would not be in trouble here.
Restart vim and enjoy your folding. Hope that helps.

Reformatting text (or, better, LaTeX) in 80 colums in SciTE

I recently dived into LaTeX, starting with the help of a WYSIWYM editor like Lix. Now I'm staring writing tex files in Sci-TE, It already has syntax higlighting and I adapted the tex.properties file to work in Windows showing a preview on Go [F5]
One pretty thing Lyx does, and it's hard to acheive with a common text editor, is to format text in 80 columns: I can write a paragraph and hit Return each time I reach near the edge column but if, after the first draft, I want to add or cut some words here and there I end up breaking the layout and having to rearrange newlines.
It would be useful to have a tool in Sci-TE so I can select a paragraph of text I added or deleted some words in and have it rearranged in 80 columns. Probably not something working on the whole document since it could probably break some intended anticipated line break.
Probably I could easily write a Python plugin for geany, I saw vim has something similar, but I'd like to know if its' possible in Sci-TE too.
I was a bit disappointed when I found no answer as I was searching for same. No helpers by Google either, so I searched for Lua examples and syntax in a hope to craft it myself. I don't know Lua so this can perhaps be made differently or efficiently but its better then nothing I hope - here is Lua function which needs to be put in SciTE start-up Lua script:
function wrap_text()
local border = 80
local t = {}
local pos = editor.SelectionStart
local sel = editor:GetSelText()
if #sel == 0 then return end
local para = {}
local function helper(line) table.insert(para, line) return "" end
helper((sel:gsub("(.-)\r?\n", helper)))
for k, v in pairs(para) do
line = ""
for token in string.gmatch(v, "[^%s]+") do
if string.len(token .. line) >= border then
t[#t + 1] = line
line = token .. " "
else
line = line .. token .. " "
end
end
t[#t + 1] = line:gsub("%s$", "")
end
editor:ReplaceSel(table.concat(t, "\n"))
editor:GotoPos(pos)
end
Usage is like any other function from start-up script, but for completness I'll paste my tool definition from SciTE properties file:
command.name.8.*=Wrap Text
command.mode.8.*=subsystem:lua,savebefore:no,groupundo
command.8.*=wrap_text
command.replace.selection.8.*=2
It does respect paragraphs, so it can be used on broader selection, not just one paragraph.
This is one way to do it in scite: first, add this to your .SciTEUser.properties (Options/Open User Options file):
# Column guide, indicates long lines (https://wiki.archlinux.org/index.php/SciTE)
# this is what they call "margin line" in gedit (at right),
# in scite, "margin" is the area on left for line numbers
edge.mode=1
edge.column=80
... and save, so you can see a line at 80 characters.
Then scale the scite window, so the text you see is wrapped at the line.
Finally, select the long line text which is to be broken into lines, and do Edit / Paragraph / Split (for me the shortcut Ctrl-K also works for that).
Unfortunately, there seems to be no "break-lines-as-you-type" facility in scite, like the "Line Breaking" facility in geany. not anymore, now there's a plugin - see this answer
Well, I was rather disappointed that there seems to be no "break-lines-as-you-type" facility in scite; and I finally managed to code a small Lua plugin/add-on/extension for that, and released it here:
lua-users wiki: Scite Line Break
Installation and usage instructions are in the script itself. Here is how SciTE may look when the extension properly installed, and toggle activated after startup:
Note that it's pretty much the same functionality as in geany - it inserts linebreaks upon typing text - but not on pressing backspace, nor upon copy/pasting.
the same but more easy, I think...
put this in the user properties:
command.name.0.*=swrap
command.0.*=fold -s $(FileNameExt) > /tmp/scite_temp ; cat /tmp/scite_temp >$(FileNameExt)
command.is.filter.0.*=1
Ciao
Pietro

I get this window while editing Ruby Files in Vim. What is it?

I usually get this new window open up suddenly while I am editing a Ruby file in VIM. This is getting irritating because, i cant type in anything while its processing. And it usually happens arbitarily. Does any one here know which plugin could be doing this? Or is this somekind of VIM's process?
This is happening when you hit K in normal mode.
K Run a program to lookup the keyword under the
cursor. The name of the program is given with the
'keywordprg' (kp) option (default is "man"). The
keyword is formed of letters, numbers and the
characters in 'iskeyword'. The keyword under or
right of the cursor is used. The same can be done
with the command >
:!{program} {keyword}
There is an example of a program to use in the tools
directory of Vim. It is called 'ref' and does a
simple spelling check.
Special cases:
- If 'keywordprg' is empty, the ":help" command is
used. It's a good idea to include more characters
in 'iskeyword' then, to be able to find more help.
- When 'keywordprg' is equal to "man", a count before
"K" is inserted after the "man" command and before
the keyword. For example, using "2K" while the
cursor is on "mkdir", results in: >
!man 2 mkdir
- When 'keywordprg' is equal to "man -s", a count
before "K" is inserted after the "-s". If there is
no count, the "-s" is removed.
{not in Vi}
If you notice, it's running ri in the open window, which is the ruby documentation app.
In Unixy environments, the help program normally runs inline, just displacing the vim output for a minute.
Is this using gvim, or command-line vim?
In either case, you can try monkeying with 'keywordprg' to fix the popup
Or, if you can't train yourself not to type it, you can just use :nnoremap K k to change what K does (in this case, just treat it as normal k command and go up one line).
I have this same issue on my work desktop, but not my home machine. The setups are near identical.
While stalking down a possible cause, I noticed that when I leave my cursor over a Ruby symbol such as File, Vim would popup a short description of the File class. After comparing all the various vim scripts and ri-related files that I could find, I finally settled on the only solution that worked...
Open $HOME/_vimrc and add the following line:
autocmd FileType ruby,eruby set noballooneval
Previously, I commented out a block in $VIMRUNTIME/ftplugin/ruby.vim, but Brian Carper suggested a better solution of :set noballooneval. I added the autocmd line so it is only executed with Ruby files.
If anyone figures out a true solution, please contact me. :(

Resources