Vim auto indent for lines below a parenthesis - vim

I want the Vim indentation to start the cursor right below the first character inside my openinng parenthesis, like in the below code, the 'start' is right below the 'first'. How can I do that? I have been googling about this but didn't get the exact answer I wanted. I have autoindent and smart indent ON in my vimrc. Please note that this is for C-style languages. Thanks
function_name(first, has, way, too, many, arguments, to, fit,
start, one, line);

I guess this can work in your case.
:set cino=(0
As Matt said, pleaser refer to :h cinoptions-values

Related

How to efficiently edit strings after dot in vim

In vim, I have to change someText.someTextAfterDot string to someText.somethingDifferent. The cursor is at the t in After. What should be the most efficient way to do this?
If I use 'cw' command then that removes the complete someText.someTextAfterDot including someText which I don't think is efficient because now I have to type the someText again.
Normally, I use 'F.ce' (find the last . and edit till end of current word) command and then type somethingDifferent. This seems like a lot of work as in other editors (like WebStorm or Sublime) a simple double click on someTextAfterDot can do the trick.
Is there any other more efficient way to do this in vim?
First of all cw should only go forward so only remove terDot. If cw is doing anything more then I assume you have some bad mappings.
The "inner" word text object, iw, is what you need. e.g. ciw. However if you have added . to 'iskeyword' then word's will include . and the behavior of ciw will be incorrect.
To find out where 'iskeyword' is last set use the following command:
:verbose set iskeyword?
For more help see:
:h 'iskeyword'
:h iw
:h w
:h cw
:h :verbose
My intuition would be to type bdeisomethingDifferent. I dunno that it's a great improvement, but it at least doesn't make you type the . again the way F.ce does.
I normally use change inner word for that. You simply have to type
ciwsomethingDifferent
Check the documentation for text object selection too.

vim parenthesis matching only while typing

In emacs, as you type, it will show you the matching parentheses, but there is a separate setting to highlight matching parentheses that the cursor is on. Is there something I can write in .vimrc to make this happen? Everything I've found completely turns off parenthesis matching, which is not quite what I want.
Thanks for any help!
EDIT: Addressing the comment about a possible duplicate, that answer explains how to turn on what I want to turn off. I want paren matching as I type, but I don't want highlighting when my cursor is on a parenthesis. Thanks!
" Briefly jump to the matching bracket when typing
set showmatch
" Turn off the default matchparen plugin (on demand):
NoMatchParen
" Alternatively (in your .vimrc, to completely disable the plugin):
let loaded_matchparen = 1

How to eliminate the text "[n] lines folded"

I would like a folded line to display only "-" characters: no text at all.
I have tried defining foldtext per examples here and in help:. I was able to eliminate the first line contents, which were extremely annoying and completely illogical to my thinking, but it still displays
---"3 lines folded"-------
for example.
(For me it is visually distracting and irrelevant...partly defeats the purpose of folding for me, which is to HIDE the collapsed section, not to HIGHLIGHT it, which is what this redundant message does.)
You do not say what you tried that did not work, but with
:set foldtext='---'
I see a line of dashes (full width) in place of the fold. If you want even less distraction than that, try
:set fillchars+=fold:\ foldtext='\ '
(There are two spaces after the first backslash.)
You can use following settings in your .vimrc:
set foldtext=EmptyFoldText()
function! EmptyFoldText()
return '-'
endfunction
Works fine on my vim.

How to make words invisible in vim?

In vimwiki, I can input a link like this:
[[link]]
When I put cursor on the line, [[]] is visible:
>[[http://www.google.com/]]<
When the cursor is moved away, [[]] is invisible:
>http://www.google.com/<
I notice this behavior in vim's help manual(:help vim): *vim:*(*s are invisible until I type V).
I cannot figure out how it works. Thanks for your help.
This is a feature called "conceal" that was added in vim 7.3 (if I recall correctly). For a simple example, try this.
Open a buffer and type three lines, the middle one being "foobarbaz". Then enter the following ex commands:
set conceallevel=2
syntax match Todo /bar/ conceal
When your cursor is on the "foobarbaz" line, "bar" will be visible (and highlighted with the Todo highlight group if you have syntax highlighting on). Once you move off the line, "bar" will disappear.
For more information see :help conceal and :help conceallevel.
I think that hiding text can be a very helpful feature. Think about text folding or readability of links.
To hide text Vim 7.3 has introduced the "conceal" argument. Hiding text is a well defined Vim feature. It is not a dirty trick.
See
:help :syn-conceal
:help 'conceallevel'
:help 'concealcursor'
Please note that conceal works only for syntax regions, not for matches.
I have no experience with conceal, so I can't provide an example out of the box.
Habi

How do I make vim syntax highlight a whole line?

I'd like to have vim highlight entire lines that match certain patterns. I can get all the text in a line to highlight (by doing syn match MyMatch "^.*text-to-match.*$"), but it always stops at the end of the text. I'd like to to continue to the end of the term, like highlighting CursorLine.
I've tried replacing $ with a \n^, hoping that would wrap it around. No change. (I didn't actually expect this would work, but there's no harm in trying.) I also tried adjusting the syn-pattern-offset (which I read about here: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:syn-pattern). Long story short, adding he=he-5 will highlight 5 fewer characters, but he=he+5 doesn't show any extra characters because there aren't characters to highlight.
This is my first attempt at making a vim syntax and I'm relatively new to vim. Please be gentle and include explanations.
Thanks!
(edit: Forgot to include, this is a multiline highlight. That probably increases the complexity a bit.)
It's not very adaptive as the filename (buffer) and line to full row highlight needs to be explicitly identified, but apparently the sign command can be used:
It is possible to highlight an entire
line using the :sign mechanism.
An example can be found at :help
sign-commands
In a nutshell:
:sign define wholeline linehl=ErrorMsg
:sign place 1 name=wholeline line=123 file=thisfile.txt
Obviously, you should pick a higlight
group that changes the color of the
background for the linehl argument.
source: Erik Falor, vim mailing list
From the documentation on syn-pattern:
The highlighted area will never be
outside of the matched text.
I'd count myself surprised if you got this to work, but then again, Vim is always full of surprises.
could also try
:set cursorline
:set cursorcolumn
change colors like this:
:hi cursorline
:hi cursorcolumn
using the usual term=, ctermfg=, ctermbg= etc
see this answer
VIM Highlight the whole current line

Resources