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

295
votes
3answers
87k views

How do you reload your .vimrc file without restarting vim?

Can you edit your .vimrc file in vim, and reload it without restarting vim?
198
votes
5answers
129k views

How to open files in vertically/horizontal split windows in Vim from the command line

There must be a way, something like this: vim -[option] <file-list> to open files from command prompt and not from within Vim. split windows vertically or/and horizontally in separate tabs ...
79
votes
14answers
11k views

Why arrow keys are not recommended in Vim

"Never use arrow keys in Vim!" I heard this from a random speaker, but didn't have the chance to ask him why. Also, if you don't use the arrow keys, how can you move the cursor in the Insert ...
73
votes
5answers
30k views

The best way to make MacVim's vim (console, not mvim) the default instead of Mac OS X's vim?

I installed MacVim using homebrew. (brew install macvim). If I call mvim from cmd, it opens the GUI MacVim. I would like to make vim call the MacVim's Vim ...
73
votes
6answers
42k views

How to show the current column in the statusbar in vim?

I would like to show the current column in the statusbar, as is common in many other text editors. E.g. it's good to know if you are around column 80 or above. How to show the current column in the ...
69
votes
3answers
8k views

How do you reuse a visual mode selection?

Often when editing code, I'll select a block in visual mode and do a search and replace over the block. After I make the changes, however, it leaves visual mode. How do a new find and replace over the ...
55
votes
5answers
28k views

256 color support for vim background in tmux

while using vim within tmux I can see that 256 color support is enabled. with $tput colors However changing the colorscheme in vim while in tmux will change the colorscheme on a per line basis but ...
54
votes
8answers
30k views

How can I open a file read-only from command line with emacs/vi/vim

Is there a way to tell emacs/vi/vim (from the command line) that I want to view the file in view-mode or read-only. I know how to open a file as read only if emacs/vi/vim is already running.
50
votes
6answers
27k views

Mac OS X Terminal: mouse support?

Is there a native option (ie. without installing extra soft/package/plugins) to enable mouse support in the Terminal app? Actually, I'm using a lot vim with the option set mouse=a (activating mouse ...
50
votes
3answers
22k views

How do I open a blank new file in a split in Vim?

Must be something super obvious, but I can't figure out, and Google is not helping out either.
49
votes
5answers
7k views

Invoking vi through find | xargs breaks my terminal. Why?

When invoking vim through find | xargs, like this: find . -name "*.txt" | xargs vim you get a warning about Input is not from a terminal and a terminal with pretty much broken behaviour ...
49
votes
2answers
33k views

How do I find the encoding of the current buffer in vim?

Say I am editing some file with vim (or gvim). I have no idea about the file's encoding and I want to know whether it is in UTF-8 or ISO-8859-1 or whatever? Can I somehow tell vim to show me what ...
45
votes
2answers
15k views

How to start vim without executing /etc/vimrc?

On my Linux server at work, the admins did not install cscope, and I installed it from source in my home directory and added it to the $PATH. The trouble is, the /etc/vimrc has a reference to ...
41
votes
2answers
12k views

How to get vim to open multiple files into tabs at once

Is it possible to get vim to open multiple files into tabs, similar to the way the args <path> command will open multiple files into buffers? Doing something like :tabe ./* results in the error ...
40
votes
9answers
32k views

How can I get (g)Vim to display the character count of the current file?

I like to write tutorials and articles for a programming forum I frequent. This forum has a character limit per post. I've used Notepad++ in the past to write posts and it keeps a live character ...
40
votes
2answers
7k views

vim freezes inside tmux

I'm using split panes in tmux - one being vim, other shell. Sometimes, around once a day, vim freezes. I can move between panes, perform any tmux commands, just vim doesn't react to anything. This ...
40
votes
3answers
22k views

How to add a command in vim editor?

If suppose my source code file name is "foo.c". While editing and debugging i always execute this command:- :!gcc -g foo.c -o foo;gdb foo Can I add a custom command to Vim such that If i type ...
39
votes
2answers
12k views

Reload file in vim [duplicate]

When I have a file open in vim, in this case a log file, I'd like to trigger a refresh and load any file changes into my existing vim session. I often use tail -f on log files, but as I'm using java ...
37
votes
4answers
7k views

How reverse selected lines order in vim?

For example, if I have four lines as follows: the first line the second line the third line the fourth line I want to reverse them to the fourth line the third line the second ...
35
votes
2answers
5k views

Slight delay when switching modes in vim using tmux or screen

Switching to and from insert mode in Vim is no longer instantaneous since I use tmux. After pressing Esc in insert mode, it takes a noticeable amount of time to actually get out of insert mode. After ...
34
votes
3answers
28k views

selecting text tmux copy-mode

I run tmux in VI mode. VI-like navigation in copy-mode works fine. However, I can't select any text. Neither v nor V doesn't switch to VI-like text selecting mode. What am I missing? By the way, is ...
33
votes
3answers
10k views

Reload .vimrc in Vim without restart

It bothers me when I wrote something into .vimrc and I have to close it first and open to get my changes be applied. Is there a way of reload .vimrc in Vim without closing it? E.g. I've added set nu ...
32
votes
8answers
14k views

How do I open the directory of the current open file?

If I open a file with vim dir/to/my/file.c how can I easily open the directory dir/to/my in vim's filebrowser?
32
votes
3answers
7k views

How do I change until the next underscore in VIm?

If I have this text in vim, and my cursor is at the first character: www.foo.com I know that I can do: cw to change up to the first period, because a word (lowercase w) ends at any punctuation OR ...
32
votes
4answers
17k views

How to setup a line length marker in vim/gvim?

Some GUI text editors have a vertical line which serves as line length marker (it helps keeping lines shorter than 80 chars in source code files). Is is possible to have something similar in ...
30
votes
2answers
11k views

vim cut and paste history

When I'm 'cutting' in vim, I believe there are registers that keep a history of all the recent things I've cut. How do I access those registers? For example, let's say I cut each one of these words ...
29
votes
7answers
13k views

Vim: How to synchronize NERDTree with current opened tab file path?

When I open a new tab with different path from the previous file in VIM, NERDTree will still remains the same directory hierarchy of the previous file. Is there a sync shortcut to change the current ...
29
votes
5answers
3k 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 ...
28
votes
12answers
2k views

Vim: How do you efficiently search for text?

Whenever you want to search for text in vim you would type / and then the string you are looking for. However, when the string is a long one, and you want to do this multiple times, is there a way to ...
28
votes
7answers
6k views

How to make VIM settings computer-dependent in .vimrc?

I share my VIM configuration file between several computers. However, I want some settings to be specific for certain computers. For example, font sizes on the high-res laptop should be different to ...
27
votes
9answers
23k 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 ...
27
votes
1answer
3k 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 ...
27
votes
1answer
7k views

Where does VIM (gvim/macvim) keep swap files for unsaved/unnamed buffers?

Where does VIM (gvim/macvim) keep swap files for unsaved/unnamed buffers? (If it does so at all). Background: Throughout a semi intense seminar I was taking notes in an unnamed/unsaved MacVim buffer ...
26
votes
2answers
10k views

How to get shift+arrows and ctrl+arrows working in Vim in tmux?

This is all in iTerm2 on OS X. I used to have export TERM='xterm-256color' in my .bashrc. This meant Vim in tmux did use 256 colors. And once I added set -g xterm-keys on then keyboard ...
26
votes
2answers
4k views

How can I select an html tag's content in Vim?

Is it possible to select an html tag's content in Vim? For example: <p>I am a silly butterfly</p> I would like to select "I am a silly butterfly"! I know that you can use vi" to select ...
25
votes
2answers
14k views

How does one switch between windows on VIM?

I'm using both Vim and MacVim (or well, trying to). I installed the Tagbar plugin but find it impossible to switch to the actual Tagbar window to make my selection. I've been reading loads about ...
25
votes
2answers
8k views

Is there an “include” procedure in vimrc?

I have some configuration in my vimrc. Some generic ones, and some other really specific. I would like to share this config with some co workers, but a lot of them don't need these specific ones. ...
25
votes
4answers
9k views

How to search for selected text in Vim?

I'm aware that I can use / followed by a regex to search something. And I can use ? to search backwards. And I can use n and N to repeat the search forward and backward. There are also two nice ...
25
votes
3answers
54k views

installing plugins in vim

I had a real difficulty installing vim plugins on mac. I know for a plugin to be installed it has to be seen by runtimepath. According to vim docs, this is Macintosh: "$VIM:vimfiles, $VIMRUNTIME, ...
23
votes
8answers
11k views

How to start gVim maximized?

How to make gVim automatically maximize it's window when I open it? And a cross-plataform solution, I'm trying to use the same configs in a Linux and Windows machine... I've tried the hack :set ...
22
votes
6answers
9k views

How do I edit an existing buffer in a new tab in vim?

Suppose I have started vim like this: vim foo bar Now I decide that I want each of those files in its own tab. Is there a way to do that without exiting vim and adding the -p option to my command ...
22
votes
4answers
17k views

In vim, how can I quickly switch between tabs?

In gnome-terminal, I can just press Alt + (1, 2, 3, etc.) to switch to specific tabs. I can also use Ctrl + (PgUp / PgDn) to cycle through tabs (admittedly less convenient, but it can be remapped). ...
22
votes
3answers
9k views

How can I keep the code formated as original source when I paste them to vim?

When I copy some code from webpages and paste it to VIM,I find it becomes a mess style like a ladder as follows xxxxxx xxxxxx xxxxxx xxxxxxxxxx Since it messed so regularly so I ...
22
votes
2answers
3k views

Is there a way to move a split page to a new tab in Vim?

I have opened a file in a horizontal or vertical split and which to put it in a new tab instead. Can this be done easily?
22
votes
6answers
6k 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 ...
22
votes
3answers
32k views

Vim: show line feeds & carriage-return

How can I display line feeds and/or carriage-return characters in vi/vim? I know that set list shows all the whitespace characters (?), it also replaces tabs \t etc (but that's not what I want). ...
21
votes
2answers
4k views

vim scrolls very slow 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: I run vim (MacVim) under Mac OSX with the terminal app. Here is my vimrc. Hope that it has nothing to do ...
21
votes
2answers
1k views

Use vim to edit ANY text on Linux

I come from the Mac world, where I use http://www.hogbaysoftware.com/products/quickcursor to edit text from anywhere in Vim. Is there anything like that on Linux ? I'm already using "It's All Text" ...
20
votes
6answers
24k views

Vim to replace Vi

Guys, anyone know how to change linux console editor from vi into vim everytime we execute vi? I'm using Ubuntu and Fedora Core
20
votes
8answers
12k views

Vimperator copy/pasting

I'm trying out Vimperator. I mainly wanted it for the hjkl scrolling, and I like its "hint" system for following links. These two features are really all I need; I think. I don't mind the other ...