I want my code indent like this:
switch (msg)
{
case WM_CREATE:
{
DoSomething();
}
}
But Vim always indent code like this:
switch (msg)
{
case WM_CREATE:
{
DoSomething();
}
}
My vimrc file is:
set autoindent
filetype plugin indent on
What's more, I hava tried:
set cindent
set smartindent
set cinoption=l1
But they all do not work,
I really do not know how to fix it,
Can you help me?
BYW: I am not English native speaker, please forgive me if there are any errors about grammar.
Add this to your .vimrc file:
set cino==0
That sets the indent after case to zero. You can find the various options for cindent here.
Related
kind of new to VIM so be kind please.
I want to do the following:
.css-class {
some: 'rule';
}
to:
.another-class {
.css-class {
some: 'rule';
}
}
I tried surround.vim with S{ in visual mode with the block selected. But this ends up here:
{ .css-class {
some: 'rule';
} }
which doesn't really help much. If it would add the line breaks it would help but still... What would be the best way to do it?
Use Visual-line mode, V, instead of v.
VipSB.another-class
You can also use the yS operator if you do not want to use visual mode:
ySipBi.another-class
I'm trying to turn off some of the messages in syntastic.
For example, SC20148 in bash files (it complains there's no shebang).
After looking through the documentation, it seemed that perhaps this might be done through:
let g:synstatic_quiet_messages = {
\ 'type': 'syntax',
\ 'regex': 'SC20148' }
However this doesn't seem to work. How do I turn off specific messages?
The Devil is in the details:
the variable is actually called g:syntastic_quiet_messages
the error is actually SC2148
you probably don't want to disable syntax messages.
Thus:
let g:syntastic_quiet_messages = { 'regex': 'SC2148' }
Or just:
let g:syntastic_sh_shellcheck_args = '-e SC2148'
Turn off multiple kinds of warnings in syntastic in vim:
Add this line to your .vimrc
let g:syntastic_quiet_messages = { 'regex': 'SC2148\|SC1234\|SC6789' }
Also you can do it against the message itself like this:
let g:syntastic_quiet_messages = { "regex": 'superfluous-parens\|too-many-instance-attributes\|too-few-public-methods' }
Agree with accepted answer, but wished to add some extra context.
You can run :h syntastic_quiet_messages to get the official docs with explanation of the commands.
You can use syntastic_quiet_messages or, if you have a particular filetype and checker, then use syntastic_<filetype>_<checker>_quiet_messages.
Here is a snippet from my .vimrc:
" keep some globals quiet
let g:syntastic_javascript_standard_quiet_messages = { 'regex': ['alert',
\ 'localStorage',
\ 'auth0js',
\ 'auth0'] }
Above, I am keeping global errors quiet, and use an array to list more than one item. Only wish to apply this to javascript files, using the standard style lint checker.
Snipmate triples my input. I do the following:
template[press tap here]
I get an expansion:
template <class T = >
class {
public:
() {}
~() {}
private:
};
which simply follows the definition in ~/.vim/vim-addons/snipmate-snippets/snippets/cpp.snippets
# template
snippet template
template <class ${1:T} = ${2}>
class ${3:`Filename('$3', 'name')`} {
public:
$3() {}
~$3() {}
private:
};
I have no problem with inputting {$1} and {$2} tab stops but when I enter "lala " for {$3}, i get
template <class T = int>
class lala lala alal {
public:
lala alal() {}
~lala alal() {}
private:
};
snipmate syntax is pretty simple. i'm confused on what i'm doing wrong.
I installed snipmate through VAM
call vam#ActivateAddons(['snipmate-snippets'], {'auto_install' : 0})
What I write, might be a bit biased, but I don't see any reason for using snipMate, when there is UltiSnips by SirVer. Don't get me wrong snipMate is great, or better say - was great, but now it's just so far behind the UltiSnips plugin.
Be sure to see screencasts posted in the README of this project - to see the proof of what I said above.
Good luck.
Is there a vim command to move the cursor to the parent bracket?
I have a configuration file like this one, and I want to go straight to the parent bracket. Is there a simple movement command to do this, or is there a way to combine commands to do what I want?
PARENT{ // I want to move my cursor here
CHILD { stuff... }
CHILD { stuff... }
CHILD { stuff... }
...
CHILD { stuff... } // my cursor is on this line
CHILD { GRANDCHILD { more stuff } }
CHILD { stuff... }
}
Yes. Do [{ in normal mode for that. It might not work for all languages though.
Many move commands are available at :help [.
Also you can press % and it will show your open or close bracket
It looks like [[ does what you want. And ][ moves to the bottom-most brace. (With many thanks to #Benoit for cluing me in that this might be possible...)
Lets say that i have this block of text
public function __construct() {
parent::__construct();
}
and i want to insert a new line above parrent::construct at the same level. Like:
public function __construct() {
// this is the new line.
parent::__construct();
}
how can i do this. I try'ed to do Ctrl+Enter in command mode but that will move the { down also. I managed to do it by going with the cursor to beginning of parent and do Ctrl+Enter.
Isn't there a way to do it when the cursor is at the end of the first line ? or a shortcut to jump faster to parrent ?
Try O and o in the normal mode.
Maybe you should enable auto indention? That might solve your problems.
In your .vimrc file:
:set autoindent