vim (Vi IMproved) is a text editor supporting different editing modes.

learn more… | top users | synonyms

161
votes
14answers
52k views

What are the pros and cons of Vim and Emacs?

How would you compare these editors? What are the pros and cons of each? [note] This is not meant to be answered by those who "hate one and love another" or those who haven't used both.
56
votes
3answers
38k views

Delete from cursor to end of line on VI

I know I've probably looked over this a million times in all the VI documents I've read, but I can't seem to find the delete from cursor to end of line command.
54
votes
9answers
10k views

Why can't Vim open a 100 MB text file when I have 16 GB RAM?

I have a 100MB MySQL database backup file and I have trouble to open it in Vim on my Linux box that has 16G of RAM. Vim just hangs (at least unusable). This is something I don't understand. I have 16 ...
47
votes
6answers
6k views

Exit vim more quickly

I use Vim mainly for quick edits rather than long work sessions. In that sense, I find the keyboard sequence for quitting especially laborious: Esc, Shift + ;, w, q, Enter. How to quit Vim (possibly ...
39
votes
8answers
23k views

How can I edit multiple files in VIM?

I know I can open multiple files with vim by doing something like vim 2011-12*.log, but how can I switch between files and close the files one at a time? Also, how can I tell the file name of the ...
37
votes
5answers
3k views

Becoming root from inside Vim

Sometimes I start editing configuration files in /etc using Vim, but forget to use sudo to start Vim. The inevitable result then is that after finishing my edits I encounter the dreaded notice that I ...
33
votes
3answers
2k views

How does vim steal root owned files?

Witness the following: sh-3.2$ mkdir testcase sh-3.2$ cd testcase sh-3.2$ sudo touch temp sh-3.2$ ls -al total 0 drwxr-xr-x 3 glen staff 102 19 Dec 12:38 . drwxr-xr-x 12 glen staff 408 19 Dec ...
29
votes
8answers
20k views

How to copy text from vim to an external program?

I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block. It appears to copy the text into vim's clipboard, because p will paste it. But in ...
25
votes
9answers
895 views

How to find out which file is currently opened in vim?

This may sound trivial but, on more than one occasion, I have found myself having forgotten which file in vim I have open (e.g. when I am looking through different log files and such) and the only way ...
25
votes
5answers
3k views

Why does `ESC` move the cursor back in vim?

In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to ...
22
votes
2answers
16k views

How can I set VIM's default encoding to UTF-8?

I'd like to contribute to an open source project providing translated strings. One of their requirements is that contributors must use UTF-8 as the encoding for the PO files. I'm using VIM 7.3 on ...
20
votes
6answers
2k views

Using VI keys to edit shell commands in UNIX

I used to have a co-worker who was really good at UNIX. He showed me how to use Vi key bindings to edit my shell commands. He placed the command in a file that ran every time I logged in. Since ...
19
votes
9answers
2k views

Bash commands inside vi

Is it possible to type a bash command inside vi and get the stdout? I find it often tedious to close and reopen vi just because I want to look something up in the shell.
19
votes
6answers
9k views

Vi vs vim, or, is there any reason why I would ever want to use vi?

I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that a fair about of question use vi instead of ...
18
votes
6answers
4k views

Advantages of using set -o vi

I have seen many developers using this command to set the option to vi. I never understood the real use of this? When using bash commands, what help does switching to vi provide?
18
votes
1answer
5k views

What's the recommended way of copying changes with vimdiff?

When comparing files, and updating a source code repository, I like to use vimdiff. To copy changes made from one file to the other, I usually use a key sequence like this:- Shift + V (select line) k ...
17
votes
5answers
2k views

How to yank a particular line without moving the cursor in vim?

For example How can I yank and paste Line 4 only to Line 12 without having to move the cursor to Line 4?
17
votes
5answers
3k views

vim - better colors so comments aren't dark blue?

Mostly I edit ruby files, although shell script file comments are also # Currently my comments show as dark blue on black which is really hard to read. See screenshot. How can I change their color? ...
17
votes
3answers
6k views

Buffers or tabs in vim? What are advantages/disadvantages of each approach?

I'm used to modeless editors. Only the past year I've been using vim/gvim, which has a modal approach. I'm used to tabs in all editors, since before vim all of them are used to it. In gvim, you don't ...
16
votes
1answer
2k views

Is it possible to have vim key bindings in terminal?

I'm getting used to vim bindings (like pressing w to go to word, dw to delete a word, and such) and it's modes (insert, normal, visual), and, out of curiosity would like to know: is there some kind of ...
15
votes
3answers
14k views

Comparing two files in Vim

Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim? I am aware of the :next and :prev ...
15
votes
4answers
4k views

How to get vim to work with tmux properly?

I'm trying to figure out how to get vim and tmux play together. My problem is: When I use xterm-256color I get vim to work nicely, but the background doesn't render properly. I fixed this by using ...
15
votes
2answers
6k views

What is the difference between vi and vim?

As far as I know vi is more commonly found on out-of-the-box unix systems while vim often has to be installed. Also vim stands for vi improved, but improved how? What are the main differences?
15
votes
3answers
4k views

How to fix Ctrl + arrows in Vim?

I am using Putty -> Suse box -> vim 7.2 combo for editing and want to remap Ctrl + arrows combo to a particular task. But for some reason, Vim ignores the shortcut and goes into insert mode and ...
14
votes
8answers
2k views

What are the best general purpose programming tools to complement Vim?

I've been using Vim as my text editor for a little while now and I feel like I'm taking the long way to do anything. I use ctags to tag my code base for navigation and I use grep (although ...
14
votes
4answers
1k views

Automatically create matching braces in vim

How do I automatically create matching braces in vim? It should work as follows: If I input an open brace the closing one should appear automatically and the cursor should be placed in between. To ...
13
votes
2answers
12k views

How do I get the solarized colour scheme working with gnome-terminal, tmux and vim?

There's a lot of questions around this, but it's because there are so many variables. I had to piece together instructions from many sites before I got this working. First, I could not easily set up ...
13
votes
8answers
624 views

Suggested setup for an ultra-lightweight text-based programming environment in linux

I am looking for suggestions for a setup for my particular needs. I haven't done much linux since college and want to get back into it as a hobby. I have some not-too-powerful hardware (512 MB ram, ...
13
votes
1answer
7k views

How to make Vim display colors as indicated by color codes?

In short, I'm in an effort to replace less with vim (vimpager). I have settings for scripts to spit out colors (and bold and everything nice) whenever they can. less understands the color codes and ...
12
votes
5answers
5k views

How to insert the result of a command into the text in vim?

For instance, :echo strftime(%c) will show the current time on the bottom, but how to insert this time string to the text (right after the cursor)?
12
votes
3answers
3k views

ESC key causes a small delay in terminal due to its Alt+ behavior

My terminal setup is gnome-terminal + tmux + zsh with vi bindings. In applications like vim or even in the zsh's command line vi editing mode, I need to frequently hit the ESC key but there is a ...
12
votes
2answers
671 views

What happens if I use vi on large files?

Though we were instructed not to, a colleague of mine used vi to view a large text file (server.log 3.5 GB). This filled up /var/tmp and caused some problems on the server. What caused this? Why ...
12
votes
3answers
2k views

How different is Elvis from Vim?

I've been using Slackware for a while now, which ships with Elvis as its default editor. Most other Linux distributions seem to ship with Vim, instead of Elvis. Having gotten quite used to Elvis, ...
12
votes
4answers
2k views

Replacing Multiple blank lines with a single blank line in vim / sed

Question more or less says it all. I'm aware that /^$/d will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line' Any ideas?
12
votes
2answers
6k views

Best way to upgrade vim/gvim to 7.3 in Ubuntu 10.04?

I have to use Ubuntu 10.04 at work, and cant upgrade it. I'm using Vim/gVim 7.2. I want to upgrade it to 7.3 (with Python and Ruby extension support). Which is the best way? Add an entry in ...
12
votes
3answers
2k views

Vim interface on web browser input fields?

I am looking for a browser plugin which inputs textin of input boxes with the same keyboard interface of the Vim text editor. I have adopted Vimium which makes general navigation much more effective, ...
11
votes
4answers
10k views

How to select/delete until end of file in vim/gvim?

Accidentally I managed to copy-paste a paragraph in vim a zillion times. How do I select and then delete the text from my current position to the end of file? In Windows, this would be ...
11
votes
4answers
556 views

How am I supposed to edit files on a network with Vim?

Currently I'm doing it by SSHing into a server, and executing Vim on the server. This has the benefit of not having to deal with cumbersome syntax of opening files from a remote server over SCP, and, ...
11
votes
2answers
8k views

What does the noeol indicator at the bottom of a vim edit session mean?

I open a file using vim in ubuntu, and this is displayed at the bottom of the screen. "file.py" [noeol] 553L, 16620C What does noeol indicate ?
11
votes
3answers
485 views

Line numbering in Vim

How do I enable line numbers to be displayed in Vim?
11
votes
2answers
1k views

Spell check comments in vim

I'm a C/C++ professional programmer who makes lots of spelling mistakes in comments. I want to configure vim such that the spell-checker only looks for misspelled words within comments. If necessary ...
11
votes
4answers
411 views

Is there a vim shortcut for <name of current file>?

In vim, if I'm working on a Python script, I will commonly type: :! python this_script.py to execute the script. Is there a shortcut for the name of the current file? If not, can I easily make one? ...
11
votes
3answers
3k views

How to enter a tab character in vim with SuperTab plugin enabled?

How to enter a tab character in vim with SuperTab plugin enabled?
11
votes
2answers
5k views

How do I cycle through panes inside a window in tmux like in screen?

I thought Tmux - move window to pane was the same question but it doesn't seem to be. Coming from using GNU screen regularly, I'm looking for tmux to do the same things. On of the things I do ...
11
votes
3answers
537 views

How can I constantly see the current filename in vim?

I am using vim and I need a way to always be able to see the file that I am working on without having to do ^G. I see the file name when I start vim but when I start to work and use various functions ...
11
votes
3answers
7k views

How to get VIM to display 256 colors properly

I'm trying to get 256 color theme files to work with VIM under xterm. This is peaksea how it looks for me: How it should look: I've tried following the tips on the wiki page to no avail. set ...
10
votes
5answers
551 views

VIM commenting out what I paste

I got this when trying to copy this gist on vim: https://gist.github.com/w0ng/3278077 I notice the same behaviour everywhere: If I paste something that includes a comment, everything that follows ...
10
votes
4answers
1k views

How can I paste (overwriting) with vim?

In vim I use yy and p all the time to yank and paste lines. However, if I want to replace one line multiple places in the file, I can't use yy p dd p because the dd deletes the line to the clipboard ...
10
votes
2answers
2k views

Can less invoke vim instead of the default vi when I hit the 'v' key?

I want to launch vim instead of the default vi editor when I hit v in less. Are there any settings I can modify to allow me to do this?
10
votes
4answers
20k views

How do I quit from Vi?

I started Vi on my Ubuntu machine. However I don't know Vi, and now I can not quit. I see the editor and I can write text, at the bottom line there is a label "recording". How do I quit from Vi?