Skip to main content

Questions tagged [vim]

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

Filter by
Sorted by
Tagged with
600 votes
5 answers
287k views

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

Can you edit your .vimrc file and reload it without having to restart Vim?
ivo's user avatar
  • 6,111
487 votes
5 answers
496k 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
Andrei Chikatilo's user avatar
293 votes
7 answers
242k 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 ...
Jonas's user avatar
  • 27.8k
275 votes
9 answers
318k 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). ...
Matthew's user avatar
  • 14.8k
237 votes
3 answers
128k views

How to delete all lines that do NOT contain a certain word in Vim?

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"?
digitaljoel's user avatar
  • 2,743
216 votes
5 answers
45k 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 you do a new find and replace ...
labyrinth's user avatar
  • 2,616
184 votes
5 answers
184k views

How to run Unix commands from within Vim?

How can I run Unix commands while I'm inside vim?
funk-shun's user avatar
  • 2,673
167 votes
6 answers
30k 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 afterwards....
DevSolar's user avatar
  • 4,500
160 votes
3 answers
88k views

Git on Mac: How to set Nano as the default text editor?

When I'm using Git on Mac and need to do a rebase, the Vim editor kicks in by default. I would prefer Nano – could someone please explain how to reconfigure Git to make it use Nano for rebase?
user avatar
151 votes
6 answers
44k views

How do I 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 ...
Jichao's user avatar
  • 7,570
148 votes
14 answers
67k 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 mode?
142 votes
3 answers
41k views

vim freezes inside tmux

I’m using split panes in tmux – one being vim, the other being a shell.  Sometimes, around once a day, vim freezes.  I can move between panes, perform any tmux commands, just vim doesn’t react to ...
Ondrej Slinták's user avatar
141 votes
4 answers
83k 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.
hakanensari's user avatar
  • 2,167
140 votes
14 answers
397k 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 ...
Peeja's user avatar
  • 2,909
131 votes
4 answers
130k 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 ...
Naatan's user avatar
  • 1,405
129 votes
4 answers
145k 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 vim/gvim?...
vtest's user avatar
  • 5,280
125 votes
2 answers
69k 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 /usr/...
florin's user avatar
  • 1,453
123 votes
4 answers
84k 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 ...
Nemoden's user avatar
  • 2,507
121 votes
4 answers
60k 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 ...
Ash's user avatar
  • 3,024
120 votes
8 answers
73k 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 ...
Denilson Sá Maia's user avatar
119 votes
11 answers
78k 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?
JtR's user avatar
  • 1,899
119 votes
4 answers
112k 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 ":...
Abhijeet Rastogi's user avatar
117 votes
5 answers
145k views

Selecting text in 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 switches to Vi-like text selecting mode. What am I missing? By the way, is it ...
Mantas's user avatar
  • 1,303
113 votes
6 answers
169k 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.
zarna's user avatar
  • 1,231
112 votes
1 answer
31k views

How to make Vim spellcheck remember a new word

I'm using gVim for LaTeX editing. I write lots of scientific documents with words that the vim dictionary does not know. When running through spell checking I come across words that I know are ...
Andrew Redd's user avatar
  • 1,762
108 votes
8 answers
77k 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 ...
winchendonsprings's user avatar
106 votes
3 answers
109k 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 ...
innaM's user avatar
  • 10.3k
104 votes
9 answers
63k 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 (/Users/user/Applications/MacVim.app/...
Somebody still uses you MS-DOS's user avatar
102 votes
9 answers
88k 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 ...
OwenP's user avatar
  • 1,549
101 votes
9 answers
72k views

Can I disable continuation of comments to the next line in Vim?

In Vim, if I'm typing a comment in a code file, and I hit Enter, it automatically makes the newline a comment, too. For instance, in a Ruby file: # I manually typed the pound at the start of this ...
Nathan Long's user avatar
  • 26.8k
96 votes
11 answers
64k views

brew upgrade broke Vim on OS X (dyld: Library not loaded)

I've not run brew update && brew upgrade for a long time. I just did a massive upgrade which turned out to broke my Vim. This is what I got after running vim: dyld: Library not loaded: /usr/...
Mateusz Piotrowski's user avatar
94 votes
6 answers
139k views

Vim Stuck In Insert Mode

I've been using Vim for several months now via my web host (they allow putty access). All of a sudden, the escape key has become unresponsive. I cannot exist insert or any other mode by simply hitting ...
Levi Hackwith's user avatar
93 votes
13 answers
42k 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 ...
bitmask's user avatar
  • 1,245
88 votes
2 answers
43k 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 ...
user4941's user avatar
  • 1,227
87 votes
2 answers
40k views

How to get back to insert mode in VIM when you accidentally hit C-x C-s

Given this vim session: % vim test-file.txt iHello there!C-x C-s How do I get back to insert/command mode again? (C-x C-s means Control-x Control-s, not sure if it's normal vi terminology for ...
gaqzi's user avatar
  • 1,308
86 votes
11 answers
78k 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.
Nifle's user avatar
  • 34.5k
85 votes
4 answers
35k 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 ...
Nathan Long's user avatar
  • 26.8k
85 votes
7 answers
52k 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 ...
avetis.kazarian's user avatar
85 votes
4 answers
219k views

Using vim to force edit a file when you opened without permissions

I use vim to edit a file. Sometimes, I forget to have the appropriate permissions. I run vim and the file as a read only file. I can make changes, but I can't actually write the changes. Every once in ...
andor kesselman's user avatar
84 votes
4 answers
33k views

How do I tell what syntax file is being used?

Vim is syntax highlighting my file in a funny way, and I want to know what syntax file is responsible for this behaviour. How do I find out what syntax files vim has loaded?
Edward Z. Yang's user avatar
84 votes
1 answer
81k views

Pressing "Ctrl + S" by mistake while using Vim

If you press Ctrl + s while using vim would result with vim to look like as if it is being locked/stuck without you being able to make more changes unless you press Ctrl + q. Could someone explain ...
dankilev's user avatar
  • 961
83 votes
11 answers
58k 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 ...
Jichao's user avatar
  • 7,570
79 votes
5 answers
25k 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 ...
Ton van den Heuvel's user avatar
77 votes
5 answers
28k 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 ...
davur's user avatar
  • 927
74 votes
10 answers
94k 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 is ...
mrt181's user avatar
  • 925
74 votes
13 answers
61k views

Windows Subsystem Linux - Make VIM use the clipboard?

To get this off the table now and avoid any confusion ... This is for Linux running in Windows 10(ubunutu), also known as WSL. Its not the same as cygwin and windows or stand alone linux. It is it's ...
dman's user avatar
  • 814
72 votes
7 answers
38k 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 ...
innaM's user avatar
  • 10.3k
69 votes
8 answers
37k views

Move cursor to beginning of non-whitespace characters in a line in Vim

In Vim, is there a way to move the cursor to the beginning of non-whitespace characters in a line? For instance, how can I move the cursor to the "S" in the second line below? First line Second ...
Joe Mornin's user avatar
  • 1,667
65 votes
8 answers
63k views

tmux copy mode - select text block

I'm using tmux with vi keys, and copy/paste works fine as long as you're selecting one line of text, or if you have only one window. When I want to select a block of text (multiple lines, but not full ...
Srećko Toroman's user avatar
65 votes
5 answers
192k views

How to use vimtutor?

Someone recommended me that I should use vimtutor to learn the basics of vim. But I have no idea how to use it. Is it an application? A website? This is the only link that was given during the ...
user avatar

1
2 3 4 5
75