EzDevInfo.com

vim interview questions

Top vim frequently asked interview questions

How to do case insensitive search in Vim

I'd like to search for an upper case word, for example COPYRIGHT in a file. I tried performing a search like:

/copyright/i    # Doesn't work

but it doesn't work. I know that in Perl, if I give the i flag into a regex it will turn the regex into a case-insensitive regex. It seems that Vim has its own way to indicate a case-insensitive regex.


Source: (StackOverflow)

Duplicate a whole line in Vim

How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/Resharper or Ctrl+Alt+/ in Eclipse?


Source: (StackOverflow)

Advertisements

How to exit the VIM editor?

I'm stuck and cannot escape. It says:

"type :quit<Enter> to quit VIM"

but when I type that it simply appears in the object body.


Source: (StackOverflow)

Vim delete blank lines

What command can I run to remove blank lines in Vim?


Source: (StackOverflow)

How do I fix the indentation of an entire file in Vi?

In Vim, what is the command to correct the indentation of all the lines?

Often times I'll copy and paste code into a remote terminal and have the whole thing messed up. I want to fix this in one fell swoop.


Source: (StackOverflow)

To switch from vertical split to horizontal split fast in Vim

How can you switch your current windows from horizontal split to vertical split and vice versa in Vim?

I did that a moment ago by accident but I cannot find the key again.


Source: (StackOverflow)

How to paste yanked text into Vim command line?

I'd like to paste yanked text into Vim command line. Is it possible?


Source: (StackOverflow)

Redefine tab as 4 spaces

My current setting assumes 8 spaces; how could I redefine it?


Source: (StackOverflow)

How do I make git use the editor of my choice for commits?

I would prefer to write my commit messages in vim, but it is opening in emacs.

How do I configure git to always use vim? Note that I want to do this globally, not just for a single project.


Source: (StackOverflow)

What is vim recording and how can it be disabled?

I keep seeing the recording message at the bottom of my gvim 7.2 window.

What is it and how do I turn it off?


Source: (StackOverflow)

Indent multiple lines quickly in vi

Should be trivial, and it might even be in the help, but I can't figure out how to navigate it. How do I indent multiple lines quickly in vi?


Source: (StackOverflow)

What is the in a .vimrc file?

I see <leader> in many .vimrc files, and I am wondering what the meaning of it is? What is it used for? Just a general overview of the purpose and usage.


Source: (StackOverflow)

Convert DOS line endings to Linux line endings in vim

If I open files I created in Windows, the lines all end with ^M.
How do I delete them all in once?


Source: (StackOverflow)

How to replace a character by a newline in Vim?

I'm trying to replace each , in the current file by a new line:

:%s/,/\n/g 

But it inserts what looks like a ^@ instead of an actual newline. The file is not in DOS mode or anything.

What should I do?

EDIT: If you are curious, like me, check the question Why is \r a newline for Vim? as well.


Source: (StackOverflow)

Tab key == 4 spaces and auto-indent after curly braces in Vim

How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does?

Also, how do I save these settings so I never have to input them again?

I've seen other questions related to this, but it always seems to be a little off from what I want.


Source: (StackOverflow)