EzDevInfo.com

vimrc interview questions

Top vimrc frequently asked interview questions

What's the meaning of "rc" in filenames such as .vimrc and .bashrc? [duplicate]

This question already has an answer here:

There are many file with a name containing "rc", but what's the meaning of "rc"?


Source: (StackOverflow)

VIM: Disable Swap

How does one disable swap files for VIM via .vimrc?


Source: (StackOverflow)

Advertisements

How to split existing buffer vertically in vim?

I have list of buffers in vim. I can split buffer horizontally using :sb[N] where N is the buffer number. How can I split the buffer vertically ?


Source: (StackOverflow)

put `.vimrc` into the `.vim` folder

Is it possible to put the .vimrc into the .vim folder so that I only have to sync the whole folder and not folder and file to other computers?


Source: (StackOverflow)

vim : toggle number with relativenumber

with

setl nu!

I can toggle number (on/off), similar with relativenumber

setl rnu!

how I can toggle {off,number,relativenumber} ?


Source: (StackOverflow)

Always use :set paste, Is it a good idea?

In a terminal vim, pasting clipboard data often messes up the code indent. I just knew if I uses :set paste the indent is not broken. Though, after pasting data, should I do :set nopaste again? What if I don't, what problem comes?


Source: (StackOverflow)

Disable mouse clicks in gvim on ubuntu

How do I make gvim ignore mouse clicks. I'm really sick of the trackpad making my cursor all over the place. I use xubuntu if that means anything.


Source: (StackOverflow)

How can I make the Sign Column show up all the time even if no Signs have been added to it?

I've just added the Git Gutter plugin for Vim which shows lines added/modified/deleted according to git diff. It uses the Sign Column to show characters next to each line.

At the moment the column appears on save, which is quite jarring. I'd prefer the column to always show, even if empty.

How can I make Sign Column always visible?


Source: (StackOverflow)

Time of day as conditional in Vim

I'm working on improving my .vimrc, and I want to have command inside of it that depends upon whether it is night or day. I'd like to have something like the following in the end:

if isNightTime
  " do something
else
  " some other thing
endif

What's the best way to go about this?


Source: (StackOverflow)

How do you reload your .vimrc file without restarting vim?

Can you edit your .vimrc file in vim, and reload it without restarting vim?


Source: (StackOverflow)

Where should the .vimrc file be located on Windows 7?

I recently installed vim on Windows 7 as a stand-alone binary.

Where should I put my .vimrc file?


Source: (StackOverflow)

How to make VIM settings computer-dependent in .vimrc?

I share my VIM configuration file between several computers. However, I want some settings to be specific for certain computers.

For example, font sizes on the high-res laptop should be different to the low-res desktop. And more importantly, I want gVIM on Windows to behave more windowsy and MacVim on OSX to behave more maccy and gVIM on Linux to just behave like it always does. (That might be a strange sentiment, but I am very used to switch mental modes when switching OSes)

Is there a way to make a few settings in the .vimrc machine- or OS-dependent?


Source: (StackOverflow)

How to start vim without executing /etc/vimrc?

On my Linux server at work, the admins did not install cscope, and I installed it from source in my home directory and added it to the $PATH. The trouble is, the /etc/vimrc has a reference to /usr/bin/cscope which does not exist and everytime I start vim, it complains about that and I have to press for that message to go away.

It is interesting that if I remove cscope from my $PATH, I don't get that behavior - so it is possible that vim is testing that cscope exists somewhere, and only then executing the cscope configuration - but then it gets it wrong!

So my question is: can I set something up in my .vimrc so it does not source the global /etc/vimrc? I don't want to move cscope out of PATH, as I don't want to type the full directory name every time I run it from the command line.


Source: (StackOverflow)

How can I make .vimrc read from an external file?

I'd like to modify my .vimrc to read the value of a variable from an external file. How can I do this?

Specifically, a friend and I share a git repo with our .vim files, but there are a few small differences in what we want in our configs. So most of the file is common, but we use if statements to determine whether to load user-specific sections, like this:

let whoami = "user2"
if whoami == "user1"
...

After checking our common .vimrc out of source control, we each have to change the let whoami assignment so our own section will be loaded. Instead, I'd like to keep a separate file, which can be different for each of us, and from which vim will load that variable value.

Maybe another angle on this is: Will vim automatically read all the files in my .vim directory? If so, we could each put a symlink in there called username.vim, and link that to an external file that would be different for each of us.


Source: (StackOverflow)

vim not loading _vimrc file when launched from git bash

I have downloaded and installed git for windows (msysgit) and frequently used the included git bash. Whenever I run vim from git bash my _vimrc file is not loaded because there is syntax highlighting or anything. When I run the same command to start vim form with in windows command line (cmd) instead of git bash it works as described in my _vimrc file. The only customization I have done to git bash is to add the following bash_profile to C:\Program Files (x86)\Git\etc

alias up='cd ..'
alias ls='ls --color'
alias la='ls -a'
alias vimconfig='vim /c/Program\ Files/Vim/_vimrc'
alias gvimconfig='vim /c/Program\ Files/Vim/_gvimrc'
alias bashconfig='vim /c/Program\ Files/Git/etc/bash_profile'
LS_COLORS='di=36:fi=37:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'
export LS_COLORS

Does anyone know why it loads my _vimrc file correctly when vim is launched from cmd and incorrectly when launched from git bash?


Source: (StackOverflow)