vim

why can't I comment lines in visual mode

I want to comment several lines in my .vimrc, the usual way I do it is :x,ys/^/"/ and x stands for the start line number and y stands for the line number of the last line. I read some post which said in visual mode this task can be done by the following step: 1 Select your lines with VISUAL BLOCK 2 press I to insert before all highlig...

Vim (Windows) - new help files do not work

I have downloaded several new plugins which come with a help file. None of them seem to work from within Vim. I have the Windows version of gVim and the install dir contains a folder called: vimfiles vim72 Both folder contain a plugin and doc folder. Where am I supposed to put the plugin? So when I use :help [helpfile], it says it ...

gvim "open in new window" should change directory to the one of the current file

Hi I'm working in gvim with sessions and tabs, and everything works great. However there is something that is bothering me. Say I have two files open: /A/B/foo.ext and /C/D/E/bar.ext, the latter being opened last. Now say I want to open /A/B/foobar.ext. I have to go through the hassle of navigating upwards to / and from there to /A/B. ...

open a file under cursor in a split window

I often jump from a file to file, while working a large codebase. I typically do this by way of putting cursor on the file, say foo.h, and typing "gf". I wonder if I can do the same thing, yet open the file in a split window. One obvious solution is to simply type: vsp (sp) filename. ...

Vim - ex mode command - is there any way to move the cursor position?

In a one line Vim ex command: I am trying to do a command and then move to another location and execute the same command. is there any way to move the cursor position (need both left/right and up/down)? ...

How to map keys in vim differently for different kinds of buffers

The problem i am facing is that i have mapped some keys and mouse events for seraching in vim while editing a file. But those mappings impact the functionality if the quickfix buffer. I was wondering if it is possible to map keys depending on the buffer in which they are used. EDIT - I am adding more info for this question Let us cons...

vim :make automatically jumps to first file with error

When executing :make from vim, after make is complete it automatically jumps to a file with errors. Is there a way to avoid this EDIT This is usecase i want to achieve I want :make to execute then quicklist to open but the current file which i am working on should not be switched to the one with errors with default settings after :mak...

Vim, vimgrep, and file caching

My entire source code base is < 20MB. I want it all loaded in memory in the background. So that when I do vimgrep */.cpp */.cxx */.hpp , it doesn't ahve to do file IO since vim has loaded all the files into memory already. How can I achieve this? Thakns! ...

With vim, how can I use autocmd's for files in subdirectories of a specific path?

I am trying to figure out how I can define an autocmd that influences all files under a specific path. The autocmd I have tried is something like autocmd BufNewFile,BufRead /specificPath/** imap <buffer> .... Now, I'd expect this autocmd to be used if I edited, say, /foo/bar/specificPath/baz/something/bla.txt, but not if I edited /fo...

Unable to define a mapping including the '.' key

I am trying to define a mapping for Ctrl+. as follows: map <C-.> :bn<CR> This does not work. Typing Ctrl+. just results in repeating the last action just as you would get when typing .. Note that I do not want to change the behaviour of .. Any idea how to get this to work? ...

Override colorscheme

I often find myself wanting to change just something little in a colorscheme, but i don't want to edit the original file. I tried putting my change in '~/.vim/after/colors/blah.vim', but that doesn't work for me. Example, I want to change the CursorLine highlight in BusyBee.vim.. ~/.vim/colors/BusyBee.vim I create the file '~/.vim/a...

Vim: Changing pattern if nothing found?

If I ran a search pattern and nothing was found, is there a shortcut to bring it back for me to edit? ...

Vim: Searching and Replace regex fails

Content: 1. Text is here. 20. More text. Why does this Vim search and replace string fail? :%s/^\d+\.\s+/# /g ...

Becoming better at Vim

I've been using Vim for quite a long time, but I'm at a level where I use insert mode most of the time, and I still use the arrow keys to move around(!). I feel like I'm not getting the best out of my lovely editor, particularly regarding navigating (especially code), copy & pasting, and doing other manipulations of existing code. (thou...

VIM equivalent for (something like) 6xi?

There's a command in VIM where you can say how many chars to replace, and VIM will put a "$" at that many characters out, and you can type in the replacement for those characters. The original and new text can be different lengths. What's the command for this? ...

Command to surround a character with spaces in vim

I am trying to use vim properly - to aid me I've mapped my arrow keys to "" so that I am forced to use {hjlk} to move around. This is causing me a problem when I want to just surround a character with spaces, eg: "2+3" is better formatted "2 + 3" Previously I would have put my cursor over the + and typed: i[space][arrow-right][s...

Vim jump last mark-different file

:bn , :bp just switches buffers I want something like ctrl-o, which has a 'stack' of marks it jumps through. However, I want it to ignore marks in the same file ... i.e i want ctrl-my-o to be ctrl-o until you hit a different file and ctrl-my-i to be ctrl-i until you hit a different file Is there somethig like this in vim? ...

vim autoindent buffer on enter & exit

For writable buffers, is there a way to tell vim to autoindent a file on entering & exiting the buffer? What I want is the equiv of: 1G=G to go first line indent .. until last line Thanks! ...

vim: search replace over all writable buffers

so 1GvG:s/..../g can replace over an entire buffer However, suppose I have multiple vim buffers loaded, and I want to do a :s over all the buffers that are writable; is there a way to do this in vim? ...

VIM plugin for updating C++ function definition

I'm looking for a VIM plugin that can do these kind of thing. Let's say I have a function in a .cpp file void myFunction(int arg1, int arg2, int arg3){ //code } The function definition is defined in the .h file. So every time I change the function name or add a new argument to the function, I have to go back the the .h file to do ...