Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor.

learn more… | top users | synonyms

32
votes
2answers
4k views

Can't resize vim splits inside tmux

Everything is working fine outside of tmux. But in tmux I can't resize vim splits with the mouse. I have set mouse=a in my .vimrc. Is there a solution for this? .tmux.conf: $ cat ~/.tmux.conf set-...
32
votes
1answer
10k views

vim delete all lines that do NOT contain a certain word

In vim I can delete all lines that contain the word "price" with this :g /price/d How can I delete all lines that do NOT contain the word "price"?
24
votes
2answers
15k views

How to run Unix commands from within Vim?

How can I run Unix commands while I'm inside vim?
19
votes
8answers
9k views

VIM: “sudo vim bad_idea”?

An irc-user in #Vim urged me not to use Sudo with Vim like: sudo vim bad_idea When I am doing things in locations such as /var/www/, I cannot write without it. So not-using sudo becomes a problem. ...
37
votes
10answers
55k views

What's the easiest way to delete Vim swapfiles I've already recovered from?

Sometimes Vim crashes and leaves me a swapfile. That's awesome. Then I open the file I was editing and Vim asks me if I want to recover. I do, thanks. When it's done, Vim tells me, You may want ...
36
votes
9answers
31k views

How to remove this symbol “^@” with vim?

I have some files that are corrupted with this symbol: ^@ It's not part of the string; it's not searchable. How do I substitute this symbol with nothing, or how do I delete this symbol? Here ...
25
votes
7answers
7k views

How do I replace-paste yanked text in vim without yanking the deleted lines?

So I usually find myself copying text from one point to another while overwriting old text where the new is pasted: blah1 newtext blah2 wrong1 blah3 wrong2 blah4 Suppose I visual-mark newtext and ...
13
votes
1answer
5k views

How can I use the Homebrew Python version with Homebrew MacVim on Snow Leopard?

Note: For Mountain Lion, see: How can I use the Homebrew Python with Homebrew MacVim on Mountain Lion? I've installed Python 2.7 with Homebrew on Mac OS X Snow Leopard. When I install MacVim using ...
27
votes
1answer
11k views

Can't run Vimdiff (7.4) on Windows 7

I recently installed the 7.4 version of gVim on a Win 7 machine. Trying to diff two files from the context-sensitive menu on Windows Explorer, I keep getting the error messages: E810: Cannot read or ...
21
votes
3answers
5k views

Vim scrolls very slowly when a line is too long

I would never have thought that Vim would be so slow. All I have is the following long line: (Click image to enlarge) I run Vim (MacVim) under Mac OS X with the terminal app. Here is my vimrc. I ...
10
votes
5answers
9k views

What could cause strange characters in Vim?

I'm have this really strange problem in Vim using the NERD tree plugin, where, as you can see in the picture, the characters are showing up very strange. Where there is the ahat, ~V 3/4 it should be |-...
22
votes
5answers
29k views

How can I recover the original file from a .swp file?

I tried opening the .swp file using vi and cat but it displays junk.
20
votes
3answers
43k views

How to install vim.full in Ubuntu?

I've installed Ubuntu Server but I have only vim.basic? How do i install vim.full? Tried with aptitude install vim but it said it's always installed. Because vim is a soft link to vim.basic.
12
votes
3answers
6k views

How to install VIM on Linux when I don't have root permissions?

I've got some troubles when I try to install Vim on Linux while I don't have a root account. The error information is shown below: How can I solve this? Can I install it in another directory other ...
10
votes
2answers
2k views

how do I copy/paste in vim ex mode

I'm increasingly frustrated by typing this :%s/some_really_long_string/some_other_really_really_long_string_that_may_or_may_not_related_to_the_first_one/gc Is there any way to copy/paste those ...
33
votes
5answers
5k views

Vim - select text highlighted by search?

In vim, I often perform searches to hop to a word or phrase instead of navigating there with h/j/k/l. Then I hit n to hop between occurrences. Say I've got this text: Time flies like an arrow; fruit ...
12
votes
3answers
4k views

How can I distinguish current operating system in my .vimrc?

I use Vim on both OS X and Windows, with almost identical configuration. I would like to be able to use the same .vimrc on the two operating systems, but there are a couple of things I need to ...
10
votes
3answers
8k views

How to run vimtutor on windows?

I'm running vim on Windows 7. It works, but when I type vimtutor on the command line, a window opens and closes immediately, and nothing else happens. Is there a way to run vimtutor with Vim for ...
8
votes
4answers
10k views

I just got a Mac! How do I do “end” , “home”, “page up” and “page down” in my terminal/VIM editor?

I write a lot of python in my VIM, on the terminal. What do I do?
6
votes
4answers
8k views

Vim and mouse with ssh from Mac to Linux

I certainly know it's possible to make the mouse work in Vim on a remote session to a Linux machine from my Mac, but I haven't figured out just how. Daily vim gives a tip on making it work but if I ...
5
votes
3answers
3k views

Vim command to map CapsLock to Escape

What command do I have to enter to be able to leave editmode by pressing CapsLock in Vim?
21
votes
8answers
7k views

How to make Emacs read buffer from stdin on start?

With Vim I can easily do $ echo 123 | vim - Is it possible to do with Emacs? $ echo 123 | emacs23 ... Emacs starts with a Welcome message $ echo 123 | emacs23 - ... Emacs starts with an empty *...
12
votes
1answer
4k views

How can I tell Vim to show ANSI escape codes properly?

I'm trying to view and edit a file in Vim, but this file has ANSI escape codes: ^[[1m[0.05s elapsed, 00:00:13 total]^[[0m How can I tell Vim to interpret them properly instead of just showing the ...
11
votes
6answers
6k views

Vim configuration slow in Terminal & iTerm2 but not in MacVim

Ideally, I want to use Vim from Terminal or iTerm2. However, it becomes unbearably slow so I had to resort to using MacVim. There is nothing wrong with MacVim, however my workflow would be much ...
7
votes
2answers
299 views

Is it possible to not trigger my normal search highlighting when using search as a movement?

When I do a search in vim, I like to have my results highlighted and super-visible, so I give them a bright yellow background and a black foreground in my .vimrc. " When highlighting search terms, ...
6
votes
2answers
3k views

creating a simple vim syntax highlighting

i have a simple sort of a database file which consists only of entries in the following format variable=value i want to create a simple vim syntax highlighting for it and set it for specific ...
5
votes
1answer
4k views

tmux: enable mouse scrolling in vim instead of history buffer

I have just started using tmux 1.8 recently, after working with screen for a while. After reading things here and there on the internet, I came up with following ~/.tmux.conf However when I open vim ...
47
votes
4answers
11k views

How do I get the numpad to work in vim using iterm2 on osx with term=xterm?

My numpad works in iterm2 (bash), but it inserts characters instead of numbers in insert mode for vim. How can I get vim to recognise the correct escape codes. I have tried editing the escape codes ...
25
votes
4answers
7k views

save in insert mode (VIM)

I am new to vim, Usually, I find myself wanting to save and stay in insert mode, rather than hit escape, :w and back into insert mode.
10
votes
6answers
6k views

Custom vim highlighting

I am editing some xml right now and I have been leaving myself some comments of things to come back to. Like this <!-- Question: bla bla --> I am editing with vim right now and I would like ...
6
votes
4answers
885 views

VIM destroys symbolic links under Windows

It seems that when working with a file in VIM it primarily uses a backup version of the file then overwrites the original on save. This is a problem when using symbolic links under Windows (e.g. ...
6
votes
1answer
821 views

How to open many tabs for many files in vim?

I can open one file in a new tab with: :tabnew file Let's say I have many files, for example: util.h and util.cpp. How I can open those files all in separate, new tabs? I'm looking for ...
5
votes
2answers
1k views

Weird insertion from Vim on mouse click

I'm using putty (on windows 7) to connect to shell and Vim as editor. I also have mouse=a option enabled in Vim, but I get some strange behavior (such as random insertions of characters and/or ...
1
vote
1answer
837 views

How to keep cursor horizontal position while scrolling in VIM?

Is it possible to keep cursor in constant horizontal position (column) while scrolling window (or moving cursor) up and down? For example if I have file with such lines: This.is.a.test Short.one ...
0
votes
4answers
5k views

Open a text file in cygwin's VIM

Is there any way to configure Windows to open text files in Cygwin's VIM instance? I am currently using GVIM but I find it limiting for many reasons. Unfortunately, I can't just install Debian on this ...
13
votes
10answers
4k views

Emacs equivalent to VIM ci"?

Does emacs have the equivalent of VIMs ci" command? Basically I want to replace the text inside a set of quotation marks. In vim I can ci) or ci] or ci} to "change inner *"...
9
votes
6answers
4k views

bashrc: how to know X window is available or not?

There is a part in my ~/.bashrc, which sets $EDITOR to be gvim. It works fine when I am in X window. However, if I ssh to my workstation (from another workstation) gvim starts to complain "cannot open ...
9
votes
3answers
1k views

gvim redraw failure

I have a problem with gvim where the screen redraw partially fails. It's hard to explain but when I open a text file and page down or up the entire text file is not redraw properly. I have to move the ...
8
votes
5answers
5k views

Tips for using vim as a log viewer

As a log viewer, which of vim's features are convenient? less -F is quite good. But I believe vim could be better if we knew its hidden features. * or # v//d g//d etc.. PS. I don't use ...
6
votes
3answers
852 views

gVIM breaks symlinks on windows?

I'm trying to keep my gVIM config in centralized place. For this, i have done mklink c:\users\me\.vimrc c:\users\me\configs\_vimrc That works fine until i change $MYVIMRC inside VIM. This instantly ...
4
votes
4answers
1k views

Features of Emacs that are complementary to Vim?

I've been using Vim extensively for a while now, and I really enjoy working with it. However, I keep reading praises for Emacs. I've decided to take a look at Emacs to round out my knowledge of the ...
4
votes
1answer
1k views

Vim enable mouse scroll only - not cursor positioning

I want to enable the mouse wheel for scrolling like ^e and ^y do. I don't want clicking in a buffer to move the cursor though, so :set mouse=a does not help me. Reason is that I have a bunch of gui ...
3
votes
2answers
1k views

Settings in my .vimrc file are being superseded by other things - vim-gnome on ubuntu

I installed vim-gnome on ubuntu. I notice that things I put in my $HOME/.vimrc file, like colorscheme and so on, are being overwritten by something else. If I start Vim, another colorscheme is used, ...
2
votes
1answer
1k views

Running vim in Console2 does not show colours properly

So I am currently using Console2 for my command line stuff, the background shell is just the cmd.exe from windows. My problem is that I have the theme set to 'twilight` in vim, and it works perfectly ...
1
vote
1answer
638 views

Vim has unexpected key presses on startup, what could be causing this?

Whenever I open a file with vim, the vim session starts with 2c having been automatically/programmatically 'pressed'. This means that if I start off trying to move down the file by pressing j, then ...
0
votes
2answers
398 views

Editor of txt files for Windows with syntax highlight and foldable/collapsible sections for Markdown [closed]

I asked the same for Notepad++, but in fact I don't mind changing of software. I am interested in managing txt files that contain Markdown. I would like to find an editor of txt files for Windows ...
10
votes
1answer
687 views

Different background color for multiple filetypes in vim

Is it possible to have different background colors in vim (ie. one light, one dark) when dealing with files with multiple filetypes (ie. :set ft=html.php)? In PHP code with HTML embedded, it can be ...
8
votes
1answer
292 views

How to navigate 'logical' lines individually in vim?

I know that there is a setting for this in vim, I just can't find it now... Basically, I like set wrap. I like it alot. I'm less fond of it skipping down to each actual line, rather than the more ...
8
votes
2answers
2k views

How do I map <cmd>-<shift>-f to run Ack plugin in Vim?

I'm new to vim and I'm trying to map a key combo for running the Ack plugin found here: https://github.com/mileszs/ack.vim I want to map cmd-shift-f to run the Ack command :Ack. I've added the ...
8
votes
3answers
4k views

Vim: How to handle Unicode files with text in multiple (more than two) languages?

What settings do I need to set in Vim/gVim to be able to view Unicode text files which have text in many languages? You may make these assumptions: The number of languages is more than two. Some of ...