macvim interview questions
Top macvim frequently asked interview questions
So far, I've figured out swapping splits laterally via CTRL+W x
, and that's pretty much it.
How do I move a split anywhere in a viewport that contains multiple vertical and horizontal splits?
How do I create a horizontal split that, say, spans the entire top half of the screen after I have already opened a few vertical splits? (Currently, when I create a new horizontal split in an already-vertically-split viewport, I get a horizontal split in one of the columns.)
Perhaps most vim users prefer tabs over splits, but I really like the latter because I work on a 30" monitor! :-)
Source: (StackOverflow)
I can remap unused combinations like <d-1>
(Cmd+1) in MacVim, but there are many combinations like <d-f>
, <d-o>
or <d-b>
that are already bound to MacVim menu items. If I try to remap those inside my .vimrc, nothing changes.
Is there some way I can remap those combinations inside MacVim, or stop MacVim from assigning them to menu items so they are properly passed on to the Vim core?
Source: (StackOverflow)
In Vim, is there a way to move the cursor to the beginning of non-whitespace characters in a line? For instance, how can I move the cursor to the "S" in the second line below?
First line
Second line
If it matters, I primarily use MacVim, but I'd also like to be able to do this from the console.
Thanks!
Source: (StackOverflow)
Whenever I Launch MacVim it takes up the whole screen. I don't want this. Is there any way to prevent it from happening?
I run OS X 10.8.
Source: (StackOverflow)
Specifically, I'm trying to install NERDtree. I downloaded the 4.10 package from github, unzipped it into ~/.vim/
, and restarted MacVim (version 7.3).
Typing :nerdtree
results in the following error:
E492: Not an editor command: nerdtree
In terminal, typing:
cd ~/.vim
ls -R
Results in:
Rakefile doc nerdtree_plugin plugin
./doc:
NERD_tree.txt
./nerdtree_plugin:
exec_menuitem.vim fs_menu.vim
./plugin:
NERD_tree.vim
What am I missing?
Source: (StackOverflow)
The default window size appears to be 24x80 but I'd prefer to set it so new windows appear in the size 50x90. Is there a way to set this default?
Source: (StackOverflow)
I would like to add some padding between my text and the left edge of the window (or the right edge of the line numbers).

Source: (StackOverflow)
I want to be able to switch buffers (:bn! / :bp!) in MacVim, using shortcuts like
Alt (Option) - Left Arrow Key/Right Arrow Key
So far I wasn't able to do that.
Here's my mapping for the keys, which works perfectly fine in Linux, but not on MacOS:
map <M-Right> :bn!<CR>
map <M-Left> :bp!<CR>
Source: (StackOverflow)
Is there a way to forward-delete in insert-mode in vim? I'm using a MacVim. I tried "Control-D", but it obviously doesn't work. I'm searching the official documentation, but cannot find. Any help would be appreciated.
Source: (StackOverflow)
A few months back I switched from Textmate to Vim. Overall I really love Vim, but one of the things I miss from Textmate is using the ⌘R command to run Ruby code and having the results neatly pop up in a new, scrollable window. Obviously, Vim is capable of running Ruby code and displaying the output with :w !ruby
. The only downside to this is that if the resulting output is too long I can't scroll through it.
To combat this problem I tried modifying a :redir
function from Vim Tips. It looks like this:
function! TabMessage(cmd)
redir => message
silent execute a:cmd
redir END
tabnew
silent put=message
set nomodified
endfunction
command! -nargs=+ -complete=command TabMessage call TabMessage(<q-args>)
Now the output from Ruby is put into a new tab. However, I can't get it to pop up in a new, separate window. Changing tabnew
to new
just sends the output to a split in the same window.
The other problem is that a visible ^M
gets appended to the end of each line, so the output ends up looking like this, which is kind of bothersome:
Hello World!^M
So, is there any way to get the output into a separate window without the ^M
appended to the end? Are there any plugins I should be using in order to achieve this Textmate-like effect for code output?
Source: (StackOverflow)
I use MacVim (snapshot 51)
to edit a the Python/HTML/etc files in moderately sized project. Every few months my system locks up or crashes, and Vim leaves a plethora of .*.swp files around. When I go to re-open Vim after the crash and edit any of those files, I am told "Swap file ''.xyz.swp'' already exists!" with the options of [Abort] [Quit] [Delete it] [Recover] [Edit anyway] and [Open Read-Only].
This recovery option would make sense if there were changes to the Vim buffer that hadn't been saved at the time of the crash. However, at the time of the crash these files were opened in the background of Vim, and unchanged.
If possible, how can I configure Vim to not ask this superfluous question when opening files for which there are no changes between the .swp
file and the actual file, e.g. by one of:
Automatically comparing the changes in the .swp file to the file, and if there are no changes then just opening the file without prompting;
Not keeping a .swp file for files that have no changes.
Any other means of systematically avoiding this pointless prompt (but I'd prefer not to avoid the prompt in cases where, of course, there were unsaved changes).
I have over fifty .swp
files to clean up at the moment, and the pointless prompt is a frustration I'd be grateful to avoid.
Thank you for reading.
Brian
Source: (StackOverflow)
I'm a Mac Noob but generally a power Linux user. My new job handed me a fresh MacBook Pro with Lion installed.
I installed MacVim successfully using homebrew. I'd love for it to be the default app for opening certain file types. (.rb, .haml)
But when I attempt to assign MacVim as the default app in the Finder, the app is unheard of. A Spotlight search on MacVim turns up only the original .tgz file.
Yet I can run it from a command line (mvim) and pin it to the dock and run it from there.
I'm guessing something called an "alias" needs to be created, and I get the impression this is something different from a symbolic link. Indeed I have a symbolic link in my ~/Applications folder for MacVim, created there by homebrew.
How can I somehow bless MacVim to be an installed app and assign it to open certain file extensions?
Source: (StackOverflow)
I have the following lines at the bottom of my .vimrc.local:
set textwidth=0
set wrapmargin=0
However, whenever I open a new file, both these values are set to their defaults (72 and 2, respectively) and not my custom settings. The other settings in my .vimrc.local file appear to be set (tabs, etc) but just these two keep being reset. If I enter :source ~/.vimrc.local
the settings change and work correctly.
Is there a way to look at what is setting anything when vim starts up? I suspect that some plugin or setting that came with MacVim or Janus is setting these options, but I don't know how to look at every setting at once.
Source: (StackOverflow)
I recently started using Vim with NERDTree. The annoying thing is when I close the buffer, NERDTree expands to fill the rest of the screen, and I have to open another file and reopen NERDTree to get it back to the old layout.
Is there a way to "lock" NERDTree in place? Ideally, closing a buffer would replace it with another buffer that's hidden, or open a new blank buffer if no other buffers are open.
Thanks!
Source: (StackOverflow)