vim (Vi IMproved) is a text editor supporting different editing modes.
142
votes
14answers
38k 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.
45
votes
6answers
3k 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 ...
43
votes
3answers
25k 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.
33
votes
6answers
17k 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 ...
33
votes
4answers
2k 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 ...
32
votes
3answers
1k 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 ...
26
votes
8answers
16k 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 ...
24
votes
4answers
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 ...
21
votes
2answers
13k 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
9answers
718 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 ...
19
votes
9answers
1k 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.
18
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 ...
18
votes
6answers
5k 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 ...
17
votes
6answers
3k 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?
16
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?
16
votes
1answer
3k 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 ...
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
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
5k 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 ...
14
votes
2answers
4k 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?
14
votes
3answers
3k 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
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
8answers
1k 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 ...
13
votes
3answers
10k 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 ...
13
votes
8answers
567 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, ...
12
votes
2answers
411 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
2answers
5k 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
2answers
8k 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 ...
11
votes
4answers
486 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
5answers
807 views
vim - better coloring so comments aren't in such hard-to-read 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?
...
11
votes
2answers
6k 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
5answers
3k 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)?
11
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 ...
11
votes
2answers
797 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
356 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
273 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
1k 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
1answer
5k 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 ...
11
votes
3answers
6k 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
4answers
8k 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 ...
10
votes
5answers
529 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
3answers
466 views
10
votes
4answers
828 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
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?
10
votes
4answers
14k 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?
10
votes
4answers
1k views
Preserve modified time stamp after edit
For files within a specific folder, I would like vim to never touch "modified"
timestamp at all.
The background is that I use Bloxsom for blogging, which uses plain text
files in ~/bloxsom as source ...
10
votes
1answer
319 views
Can I make vim change its cursor behavior?
I've been using vim for a few years as a secondary editor but for various reasons, I find myself using it more and more even when my primary editor is available. One problem that has always bugged me ...
9
votes
5answers
2k views
vim: replace all character till end of line
Maybe I am being daft but can you replace all the characters from where the cursor is to the end of line by one command? Then use . to do the same replace on the next line and so on.
9
votes
2answers
1k views
Select code block in vim
Given a code like this:
588 while ($linecounter > 0) {
589 $token = " ";
590 while ($token != PHP_EOL) {
591 if (fseek($handle, $pos, SEEK_END) == ...
9
votes
4answers
453 views
Delete whitespace for a set of lines in Vim editor
I have some text like the following in a file:
sample text
some random text
even more random text
text with no indent
worst indention
I need to delete the empty space before each ...



