Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whenever I type colon in insert mode it moves my text to the very beginning of line

Tags:

vim

Whenever I type a : (colon) it moves all the text on the current line to the beginning of the line, ignoring spaces and tabs.

So if I type

var combo = new Ext.form.ComboBox({
  typeAhead //I'm about to type a colon, but right now it looks fine
})

Then I type the colon it moves the text and it now looks like

var combo = new Ext.form.ComboBox({
typeAhead: //text is no longer indented
})

This is a javascript file, so that might be causing the problem?

How can I stop my text from being moved to the beginning of the line when I type a colon?

like image 934
Grammin Avatar asked Feb 16 '23 19:02

Grammin


1 Answers

Adding a colon to the end of a token is causing vim to interpret it as a jump label for C-indenting purposes. :set cino+=L0 should cause it to stay in the current column.

Also, doesn't the JSON syntax allow you to quote the thing that precedes the colon? That should prevent vim from thinking it's a label too.

var combo = new Ext.form.ComboBox({
    "typeAhead": "foo"  // this isn't a jump label
});
like image 190
Michael Kristofik Avatar answered May 21 '23 07:05

Michael Kristofik