vim (Vi IMproved) is a text editor supporting different editing modes.
105
votes
14answers
25k views
vim vs. emacs… and no, this is not a flame war
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.
30
votes
3answers
949 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 ...
28
votes
4answers
1k 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 ...
22
votes
6answers
8k 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 ...
21
votes
3answers
2k 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 ...
18
votes
6answers
10k 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 ...
17
votes
9answers
994 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.
16
votes
3answers
7k 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.
16
votes
6answers
1k 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 ...
15
votes
6answers
1k views
Using VI 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 to edit my shell commands.
He placed the command in a file that ran every time I logged in.
Since then, I've ...
14
votes
1answer
1k 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 ...
14
votes
2answers
5k 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 ...
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
8answers
471 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
4answers
2k 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 ...
13
votes
3answers
3k 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 ...
12
votes
2answers
2k 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?
12
votes
3answers
504 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 ...
11
votes
5answers
949 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?
11
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 ...
11
votes
3answers
2k 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 ...
10
votes
3answers
416 views
10
votes
4answers
253 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? ...
10
votes
1answer
780 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 ...
10
votes
1answer
237 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
1k 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
3answers
3k 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 ...
9
votes
4answers
263 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 ...
9
votes
2answers
258 views
Trying to “locate” and then open a file
Suppose that I have a file named filename123.txt and it is the single file that is named so, and I can locate it with the command locate filename123. And it returns only this file.
Now I want to open ...
9
votes
3answers
2k 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?
9
votes
3answers
367 views
How to set on executable bit for a particular file automatically
I want that when i make create a particular file, suppose i create it in vim editor, the created file should get executable permission as well when it gets created . I want this as i am creating some ...
9
votes
2answers
804 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, ...
9
votes
2answers
296 views
How do I modify the ci command in vim
Just like "ci(" changes everything between parentheses, I want "ci$" to change everything between dollar signs (for editing LaTeX.) Is this possible?
9
votes
3answers
3k 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 ...
9
votes
3answers
535 views
GVim compiled from source opened via SSH -X does not copy paste on selection
I'm using SSH (with -X specified) from a Ubuntu box to a RHEL4 box and running GVim. It opens as expected in my local X, but the copy and paste via select doesn't work. I cannot select text in GVim ...
9
votes
2answers
317 views
Vim, context-sensitive comment/uncomment behavior
I edit a lot of PHP code with Vim, and I've run into a snag with some macros in my .vimrc.
I currently use these two macros to comment/uncomment in C-style
"c-style (//) comment (press the [.] key)
...
8
votes
4answers
5k 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 ...
8
votes
2answers
339 views
vim: Can I make *only* y perform a copy?
I'm learning to like vim, but one thing that I haven't yet fully embraced is the copy and paste situation. In a muggle text editor I would Ctrl-C copy a piece of text and then edit/delete and then ...
8
votes
2answers
1k 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?
8
votes
4answers
805 views
Why would vim return non-zero exit code if I exit immediately after opening?
I'm running into a bit of a strange problem w/ vim on Snow Leopard: I get a non-zero exit code from simply running vim and then quitting.
$ vim
# exit immediately using :q
$ echo $?
1
However, if I ...
8
votes
3answers
1k 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?
8
votes
2answers
525 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) == ...
8
votes
2answers
503 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 ...
8
votes
4answers
363 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 ...
8
votes
5answers
2k 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)?
8
votes
2answers
435 views
vim: use string from search in replace command
I often use vim / search command to verify my regular expressions (just to see what it matches). After that i usually use the :%s replace command, where i use that regexp from search as a string to be ...
8
votes
1answer
310 views
Is there a way to move by screen lines in vim?
When editing files in vim, it is a small annoyance that when I move lines with j and k, it moves by file lines, rather than screen lines like other editors. With my own files, I can deal with this by ...
8
votes
2answers
299 views
Vim command for inserting a character
I'm looking for the opposite of x. I want to insert just one character and stay in command mode.
8
votes
2answers
166 views
VIM: show all lines edited in session
Is there a command or plugin that I can use to show all the lines I have edited in a Vim session? I would like to be able to have all the changes I have made highlighted when working in co-workers ...
8
votes
1answer
458 views
Why am I getting 'Name collision between …' errors and how can I fix them?
Every time I try to launch vim or emacs or even top (I think it's actually any command that uses ncurses) in a unix terminal (on a cluster computer over ssh), I get a a continuous stream of 'Name ...
