SublimeText 4 has some more autocompletion functions, which is very nice. However, I am seeking to control these features. In particular, in a C++ code, when I type
/**
and press enter
I get
/**
*
But I'm looking to either:
remove the inserted *, or
change the default indentation.
Just to clarify the latter, by default the alignment is as follows:
/**
* This is my docstring.
but I want the first character to respect my default indentation of 4 to get
/**
* This is my docstring.
At the moment I'm not even sure which term goes along with this functionality.
Related
I'm using indentation style of C++ like LLVM, and clang-format. I need options to be like that:
set cinoptions=:0,g0,(0,Ws,l
set autoindent
set smartindent
set cinkeys=0{,0},0),:,0#,!^F,o,O,e
set cinwords=if,else,while,do,for
Problem with that, that whenever i refer to namespace and press namespace: - it triggers :0 option. When pressed second : - it triggers back. Yes, all is correct. But triggering always for : - very bad for my brain. I wanna static behavior. Not whenever i'm trying to use some namespace and press double :. I need triggering :0 only for the case in switch statement. I hope you can understand what i'm talking about. Please help.
switch(number) {
case 4: // i wanna triggering of:0 only for this line of code.
cout << "Good indentation";
break;
}
if (true) {
namespace: // NOT FOR THAT!
namespace:: // triggers back - all is correct. First triggering is very bad!
}
You're looking for L0; see :h cino-L. It's -1 by default, which means jumping to col 1. It's worth noting the wording in the documentation as well: "If N is non-negative, the indent of the label will be the prevailing indent minus N." -- that's why N = 0 works. It preserves the current indentation level by not subtracting anything from it, and through that, avoiding the jumping.
It only affects labels and not the switch statements' case x:. Note that this means if you want labels to be indented differently, but don't want jumping for the :: operator, you'll probably need to find an LSP with that type of indent support, because cino doesn't support that. You'll either have to live with it jumping on the first : and back on ::, or not having label indentation automatically differ from your normal source code indentation, and having = reset any manual changes you do to label indentation.
Anyway, it also means :0 was never actually triggered. cino's default options meant L-1 was triggered on namespace: - switch case labels aren't the same as normal labels, which meant another option was to blame.
And finally, for the sake of completeness:
set cinoptions=:0,g0,(0,Ws,l,L0
I've a syntax after file for Java. It works, cause I already defined some syntax keywords, matches and regions, which are successfully highlighted.
Not I want to highlight some matches, which are within a highlight region I defined before. My intention was that the region get highlighted first and the matches afterwards draw over this region parts.
The exact use case are the function/class/... descriptions with thei documentation keywords like #author, #version, ... Therfore I wrote the following into my syntax file:
syntax region _Comment start="\/\*" end="\*\/"
syntax match _CommentKey "^\s*\*\s*\zs#\w*\ze\s"
highlight link _Comment Comment
highlight link _CommentKey Special
No I have two problems. I test both independently and the comment region works fine. The comment key match only works without the \zs part, so it highlight also the leading *. As soon as I add the \zs nothing is highlighted anymore. How can I solve this? For other matches this works fine.
The second problem: I don't them combined. If I enable both rules, only the whole section will be highlighted as Comment. I doesn't matter where I place the second rule, it will not be highlighted. Also I tried to use the skip for the region, until I realiszed it is meant for something different.
Any ideas? Thanks!
Example code to test:
/**
* Function description here.
*
* #param id
* #author Max Mustermann
*/
private static int function foo(final int id) {
return id;
}
Syntax regions, which have nested matches must allow them:
syntax region _Comment start="\/\*" end="\*\/" contains=_CommentKey
Have a look at :h syn-contains
For your first Problem, you should read :h syn-pattern there you'll find the following sentence:
Syntax patterns are always interpreted like the 'magic' option is set,
no matter what the actual value of 'magic' is.
See :h magic for that. Your regex must escape # in magic mode.
"^\s*\*\s*\zs\#\w*\ze\s"
should work fine
I've noticed on occasion that that using * to search for the word under the cursor occasionally will have slightly different behavior (usually when I'm switching between various computers). The issue is when I perform a search for a word that has a * in front of it (like a c++ pointer). For example:
MyPointer *foo;
...
foo = new MyPointer();
When I move the cursor over the first occurrence of "foo", it usually does a search for that exact word (e.g. /\<foo\>), but sometimes it will include the * character in its search (e.g. /\<*foo\>) which causes it to fail to find any other occurrences of that variable since it's including the * character.
Does anyone know what causes this behavior and/or how to control it?
The behavior is affected by the isk(iskeyword) option.
It may different when you switch to a different buffer.
You can type :help 'isk' to read more.
My vim is throwing nasty errors 50% of the time when I use ctrl-n for completion
E854: path too long for completion
I really want to remap this, and call it with the :silent option to suppress the error, but I have no idea what function provides completion, so I can't remap it.
So my question is where can I find exactly what C-N calls when it is invoked in insert mode
Solution:
As mentioned in the comment on my accepted answer I found a way round this. Based off the instructions on building your own vim here : brilliantcorners.org/2011/02/building-vim-on-osx-snow-leopard
I grepped the source directory for E854 and it only comes up in 1 file. If you open that file you see it is only referenced twice. I just removed those error calls and built vim
This doesn't solve whatever the actual problem is, but it's the same effect as doing ignore. It works great now and doesn't throw any errors, I hope anyone else with this problem is helped by this.
In insert mode, <C-n> usually completes words with the content of your buffers. I don't know how it works internally but it may complain about a buffer's associated file's path length.
But I can't find a reference to E854 in Vim's :help, which can be normal if it comes from a plugin I don't have.
You could:
try :verbose imap <c-n> to locate its origin or
search the help for the tag E854, :help E854 or
search the help for the sting E854, :helpgrep E854 or
grep for E854 in your ~/.vim folder, $ grep -r E854 ~/.vim.
I had an issue like this similar. Turns out it was blowing up because the current ruby.vim that's distributed with Vim calls a deprecated Gem.all_load_paths which puts a nasty error in your path variable. Check out https://github.com/rubygems/rubygems/issues/161 and https://groups.google.com/forum/#!msg/vim_dev/wrouKpIDraU/xLxUuMT3_6QJ for a fix :)
My copy of the vim source code (obtained at some point using Mercurial and hg clone https://vim.googlecode.com/hg/) finds that error being thrown only in one spot, in the internal function vim_findfile_init():
static char_u e_pathtoolong[] = N_("E854: path too long for completion");
...
/*
* copy wc_path and add restricts to the '**' wildcard.
* The octet after a '**' is used as a (binary) counter.
* So '**3' is transposed to '**^C' ('^C' is ASCII value 3)
* or '**76' is transposed to '**N'( 'N' is ASCII value 76).
* For EBCDIC you get different character values.
* If no restrict is given after '**' the default is used.
* Due to this technique the path looks awful if you print it as a
* string.
*/
len = 0;
while (*wc_part != NUL)
{
if (len + 5 >= MAXPATHL)
{
EMSG(_(e_pathtoolong));
break;
}
...
So it looks like it's doing arbitrary-depth wildcard expansion. If I had to take a wild stab I'd say you have a path somewhere in the filesystem that has a circular symbolic link (say c -> a), so you end up doing path completion and getting /foo/bar/a/b/c/a/b/c/a/b/c/a/b/c/..... and the limit gets hit.
Edit
Scratch that last theory; based on actually reading the code, it looks like it's trying to find a tag file and blowing up. Can you post what you get when you do :set tags ?
Edit 2
Sigh, it's late... Here's the answer you originally wanted that I just found: do :help completefunc and :help completion-functions. completefunc is the one you want, if I (finally) understand your question.
The one thing I really miss in vim is a tiered intellisense support, just like we have one in PHP Eclipse.
For example:
/**
* Get the config object
*
* #return Config
*/
public function getConfig()
{
return $this->_config;
}
I find this explicit return type setting very useful and time saving feature.
Do we have something similar in vim?
Vim by itself doesn't really have any intellisense... Instead, it just provides autocompletion. This means that Vim isn't aware of language, types, etc. It just looks for strings that it can complete.
I'm not familiar with tiered intellisense, but you could try using the Vim Intellisense plugin. It does have language-specific completion and type-checking. It does not have direct support for PHP, but perhaps it will get you closer to your goal.
EDIT Using Vim's omnifunc, you can get function completion, but there is still no built-in type awareness.