110 votes

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

Solution Try to reinstall ruby and vim, e.g. brew reinstall ruby vim Troubleshooting Here are other suggestions if above won't help: Find any references to DYLD_LIBRARY_PATH, ...
kenorb's user avatar
  • 25.5k
95 votes
Accepted

How to search for selected text in Vim?

The following sequence will do what you want, given an already selected block of text: y (yank the selected text, into the " register by default) / (enter search mode) (\ V) (optional, enter "very no ...
glennsl's user avatar
  • 1,066
80 votes
Accepted

Pressing "Ctrl + S" by mistake while using Vim

Well, It's no a vim issue. This is called Software flow control. There is a bunch of info out there on the internet. According to an article in here: CTRL-S (XOFF) is part of Software flow control....
Manuel Florian's user avatar
74 votes
Accepted

vim open file in a new tab

When inside vim, I use :tabnew filename to open a file in a new tab. From the terminal, you can do vim -p filename1 filename2 to open the two files in tabs. I have added the following lines to ...
The Vivandiere's user avatar
52 votes

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

You can also use: :v/price/d to delete lines.
MOHRE's user avatar
  • 631
50 votes

Repeat last normal mode command, including moves, in Vim

it's doable even in vanilla vim, but applicability depends on your use case, ie. how often you'll need to repeat it, since it requires few more keystrokes to make it repeatable. Option 1: turn it ...
JK ABC's user avatar
  • 601
45 votes

Windows Subsystem Linux - Make VIM use the clipboard?

(Edit: Apr 2024) With the latest WSL version: 2.1.5.0 on Win11 simply having set clipboard+=unnamedplus now seems to be enough for neovim, at least with the latest Microsoft Store versions of Ubuntu. (...
AntonOfTheWoods's user avatar
45 votes
Accepted

Scroll up to in Vim term

If you press Ctrl + w, followed by Shift + n, it pauses the terminal, and you can navigate it like any buffer. Pressing i takes you back into the terminal as you were before.
Sam Rice's user avatar
  • 616
38 votes

Selecting text in Tmux copy mode

Upstream (2.4+) tmux changed how to bind for begin selection. To create a binding for what the OP is asking use -T and send-keys with -X: # Use v to trigger selection bind-key -T copy-mode-vi v ...
p1100i's user avatar
  • 990
36 votes

In vim, how can I quickly switch between tabs?

As I am on a Mac and not using MacVim (but plain vim within a terminal) I have had some difficulty with key combinations not being sent through to the terminal. The most-compatible (and for me most ...
Stefan Magnuson's user avatar
36 votes
Accepted

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

tl;dr brew link --overwrite ruby Details Actually, it turned out to be quite simple. I followed the suggestion to run brew doctor and I got these results: Warning: You have unlinked kegs in your ...
Mateusz Piotrowski's user avatar
36 votes

Why is VIM starting in replace mode?

Seems to be an issue with utf-8 ambiguous characters and Windows cmd console. Flag t_u7 is set by default and so vim will request cursor position and get a bad reply from the ssh client. Workaround: ...
Zoran Bikicki's user avatar
36 votes
Accepted

VIM Delete up until word/character

Yes, use the "till" motion. dt" means delete until a ". There is also the "find" motion, which deletes up to and including the character. Both of these work in reverse if you capitalize them. From :...
DJMcMayhem's user avatar
  • 1,052
36 votes

How to copy from vim to clipboard on ubuntu 20.04

Answer for Ubuntu 20.04 You need to make sure clipboard is activated (which is probably not the case). Run : vim --version | grep 'clipboard' if you get "-clipboard" then you would have to ...
Slim Aloui's user avatar
29 votes

Why does `zsh` insert a `~` when I press the delete key?

Answering because this was the first DDG result in searching for the same issue. First, you need to get the code for the delete key. Go to your shell prompt, for example: alec@su:~$ Execute the '...
alecdwm's user avatar
  • 391
29 votes
Accepted

how to paste into tmux from system clipboard

This post solved it. Holding 'Shift' will bring back OS-default behavior which then lets me copy with select + right-click and paste with right-click.
curiousgeorge's user avatar
28 votes
Accepted

Is it possible to use vim key bindings in iterm2?

I'm surprised you haven't yet found out about set -o vi This enables the vi editing mode in Bash (to make this permanent put the command in your ~/.bashrc file). Greg's Wiki has a short summary, and ...
Ingo Karkat's user avatar
  • 23.1k
27 votes

How do I unset a specific vim command?

There are 3 primary ways to unset a variable. I will use the binary command here for demonstration purposes. One of them should work. set nobinary set binary& set binary! Remember to reload the ...
alpha_989's user avatar
  • 1,033
26 votes

How to run Unix commands from within Vim?

In addition to the above answers, you can use the current vim buffer content as stdin for shell command using :%!. For example, suppose you want to filter lines from the current vim window content ...
Omer Dagan's user avatar
26 votes
Accepted

How do I install vim on OSX with Python 3 support?

The following works as of 26 May 2017 when a -python3 version of Vim is already installed via homebrew: brew remove vim brew cleanup brew install vim --with-python3
jacob-ogre's user avatar
25 votes

Auto-reloading a file in VIM as soon as it changes on disk

This is what worked for me set autoread ...
ErichBSchulz's user avatar
25 votes

modeline does not work in vim

I describe a full debug checklist in this other answer. I was REALLY stumped on this one because the documentation is not entirely true. It turns out that in version 8 (and maybe earlier) you cannot ...
Bruno Bronosky's user avatar
25 votes

Vim delete motions include under the cursor

Just to clarify, if you are already in insert mode, CTRL-W is fast and usually what you want. In normal mode, this may be what you're after: Prepare to have your mind blown: dvb Vim makes a ...
Braham Snyder's user avatar
24 votes

Change current directory using NERDTree

If you're inside the NERDTree buffer you can select the folder and press C to change the NERDTree root directory. Just type :help NERDTreeMenu and go to line 252 typing 252G or 252gg to check it ...
Rafael Berro's user avatar
24 votes

Adding parenthesis around highlighted text in Vim

The command c()<Esc>P Explanation If you want to put the word under the cursor in to brackets this is viwc()<Esc>P. viw will visually select all charactrs in a word. c() will cchange the ...
0-_-0's user avatar
  • 359
24 votes

vim syntax highlight limited to 3000 chars

Use :set synmaxcol=0 to remove the limit or choose any large value. Warning: This setting may add a significant redraw delay. Vim documentation: options - synmaxcol 'synmaxcol' 'smc' number (...
Steven's user avatar
  • 27.9k
24 votes
Accepted

Why does shift insert only work fully in insert mode?

Both Shift + Insert and "pasting" into a terminal behave in a similar way - they emulate key presses. This is an important distinction that is often impossible for terminals to make - are you typing ...
Attie's user avatar
  • 20k
22 votes

Show current file size in vim editor

Hit g CTRL-g to see some statistics on the current file in the status line, including file size.
thakis's user avatar
  • 331
21 votes

vim: number of total buffers

Answers so far are too hacky. Here is vim's built-in way: len(getbufinfo({'buflisted':1})) As always, see vim's help (:h getbufinfo()) for the official explanation.
Gid's user avatar
  • 421
21 votes

Windows Subsystem Linux - Make VIM use the clipboard?

This solution worked for me, thanks to github user robbiev. For completion this is an outtake from his answer: Install VcXsrv (if it starts after installing, stop it). Start it using the newly ...
Aerows's user avatar
  • 311

Only top scored, non community-wiki answers of a minimum length are eligible