Skip to main content
98 votes

Vim search replace all files in current (project) folder

Let's say we have a simple project structure like this: greeting.txt looks like and info/age.txt looks like Let's say we want to replace all occurrences of Sam with Bob. Here's what we would do: 1. ...
Niko Bellic's user avatar
  • 1,824
22 votes
Accepted

Mapping Ctrl with equal sign

Unfortunately, there's no reliable way of mapping Ctrl-=. Because of the way that ctrl+key chords interact with the terminal and are represented internally, the only Ctrl-mappings that Vim is ...
DJMcMayhem's user avatar
  • 17.8k
18 votes
Accepted

How can I fix "missing" syntax highlighting for Python keywords such as "self"?

How syntax highlighting works in brief: In syntax/<filetype>.vim the syntax rules are defined with the :syntax command. This command defines, well, syntax. It says "if text matches this regular ...
Martin Tournoij's user avatar
11 votes
Accepted

Delay before running vim command?

In recent vim versions, you can use timer_start to delay an operation. For example, to execute winpos 200 milliseconds after vim starts, autocmd VimEnter * call timer_start(200, { tid -> execute('...
Mass's user avatar
  • 14.2k
10 votes
Accepted

How to preview the result of markdown file edited in vim?

While I mostly agree with @romainl comment (markdown was made to be explicit enough not to need a preview) you can do this in different ways: [OSX / Unix] The instant-markdown plugin is a solution. ...
statox's user avatar
  • 50.4k
10 votes

Cannot map Ctrl+ number (except 6 or ^)

Normally Ctrl-Number produce a different key code. You can check like this: Open Vim and change to insert mode. Then hit Ctrl-V followed by Ctrl-4 (or whatever you plan to map). On Linux this ...
Ralf's user avatar
  • 9,337
8 votes

how to make vim properly render RTL (Right to Left) languages

Vim only supports displaying files containing mixed RTL and LTF text in a terminal which also supports this (such as mlterm). (You're not using GUI Vim, but I'll note for future readers that it is ...
Rich's user avatar
  • 32.4k
8 votes
Accepted

Can you use neovim in a gui like mvim or gvim? (Mac OS X)

There are several GUIs for Neovim because it externalises the user interface elements, so any GUI can draw these in different ways. There's a list that tracks the status of these projects. My ...
Tae's user avatar
  • 2,145
7 votes
Accepted

Visually selecting a line and then deleting does not copy to black hole register

nnoremap only affects [n]ormal mode and will not affect [v]isual mode. You need vnoremap for that: vnoremap d "_d
Tumbler41's user avatar
  • 7,776
7 votes
Accepted

Ctrl+o and Ctrl+i don't work with line skip motion 10j

You don't need a plugin, all you need is two lines of vimscript! If you would like every time you press 'j' or 'k' to be added to the jumplist, this is pretty easy. You could do it with this: ...
DJMcMayhem's user avatar
  • 17.8k
7 votes

How do I enable Bash keyboard shortcuts while in Insert mode?

Type <c-o> to temporarily leave insert mode and use normal mode keys instead. To create insert mode maps, read :h normal-index and :h insert-index. Then create insert maps that does about the ...
Tommy A's user avatar
  • 6,800
7 votes
Accepted

Are CTRL+C and <esc> the same?

<esc> and <C-c> are mostly similar. They will differ in some cases such as the following: Doing a vertical insert (<C-v>, then going down, then i to insert the same character, or ...
padawin's user avatar
  • 1,333
6 votes
Accepted

Stop vim from removing whitespace on save for diff files

Since there was nothing explicit in my .vimrc that acted on only-whitespace lines and the diff syntax file did no such thing either, this had to with my plugins somehow. I find out that I had an ...
oligofren's user avatar
  • 1,103
6 votes
Accepted

Assign shortcut to a Split window resize Ctrl+w+|

| is the command separator, so it terminates the map. You need to escape it: nnoremap <c-m> <c-w>\| Or use <bar>: nnoremap <c-m> <c-w><bar> See :help :bar and :...
Antony's user avatar
  • 2,600
6 votes

Limit buffer list to current tab

The following code will give you the file names for the current tab (if the buffer in a window is connected to a file): " Get the buffer numbers of all windows on the current tab let buffers = ...
Jürgen Krämer's user avatar
6 votes
Accepted

Why does terminal vim enter replace mode with my vimrc file?

If you are seeing a similar issue and using Windows Terminal jump down to the "Update" below. Seeing <ESC> used as the LHS of a key mapping causes me some discomfort. You've ...
B Layer's user avatar
  • 20k
5 votes
Accepted

How to not close MacVim after the last tab is closed?

You seem to be looking for MacVim Preferences, and they are under the MenuBar entitled "MacVim". MacVim -> Preferences -> General There you'll find settings for what to do on startup, and after the ...
jubilatious1's user avatar
5 votes
Accepted

How to remove these characters when tabbing on VIM

This is because of the listchars option. The idea is that you can display certain whitespace characters (tab, space, newline, etc.) as a different character so you can see them better. I'm guessing if ...
DJMcMayhem's user avatar
  • 17.8k
5 votes

How do I approach understanding the EasyGrep documentation?

Documentation of Vim plugins (rightfully) assumes that you know your way around Vim itself. I would therefore recommend that you start by finding your way around the Vim documentation and Vim itself. ...
Octaviour's user avatar
  • 982
5 votes

How to change Vim's :hardcopy printfont?

I don't know when it changed, but now it's possible. For example: :set printfont=Fira_Code:h12 :hardcopy do the job. I'm using Vim 9 on Windows. (P.S. I will try with MacVim in a few days and I'll ...
Antonio's user avatar
  • 289
5 votes
Accepted

why is the material theme looking all weird on my vim

Looking through the color settings in the theme, it's only defining the full color range for the GUI, and is using the default 16 terminal colors. Your screen shot appears to be using fairly standard ...
Drew's user avatar
  • 615
5 votes
Accepted

Can I retain and restore all the GUI windows and its files on launch on Vim?

As I mentioned in my comments a session is associated with a single invocation of Vim so you can't do exactly what you're hoping to do. But I also mentioned something might be possible using shell ...
B Layer's user avatar
  • 20k
5 votes

Can you use neovim in a gui like mvim or gvim? (Mac OS X)

I recommend neovim-qt (GitHub - equalsraf/neovim-qt). It is plain vanilla, cross-platform, stable, actively developed, and fast enough. To install on Mac using Homebrew: brew tap equalsraf/homebrew-...
otter.pro's user avatar
  • 528
5 votes
Accepted

Why does an empty vimrc file change my configuration (e.g. disable syntax highlighting)?

That's because Vim is using $VIMRUNTIME/defaults.vim as the vimrc file. If you look at :h .vimrc you'll see that Vim looks in five places for a vimrc file, stopping once it's found one. When you have ...
B Layer's user avatar
  • 20k
4 votes
Accepted

Syntax highlighting not working vim-polyglot

To be able to use the syntax highlighting in vim you must put the following line on your vimrc: syntax on Depending on your preferences/plugin manager (if any), it may want to put it at the start of ...
nobe4's user avatar
  • 16.2k
4 votes

Can't get color output in MacVim's command line

I was facing same problem with gvim on Linux. Put following in your ~/.gvimrc set guioptions+=! Explanation from :help guioptions: '!' External commands are executed in a terminal window. ...
Nilesh Kevlani's user avatar
4 votes
Accepted

Cut and copy : Blackhole and default register assignment

First off, I think your first mapping is unnecessary. Since the second d is in operator mode, it does not get remapped to "_d, so it maps out to "_dd. Secondly, you could do this: nnoremap d "_d ...
DJMcMayhem's user avatar
  • 17.8k
4 votes

How to let Gvim and Mvim source the same file, shared through Dropbox?

^M is a carriage return character. It's plain old ASCII (0x0D) and thus perfectly valid UTF-8 encoded Unicode. Vim on windows defaults to using Windows-style line endings: CRLF (Carriage Return, Line ...
8bittree's user avatar
  • 1,546
4 votes
Accepted

How to convert ISBN-10 to ISBN-13 in Vim?

I believe this does what you want. I've made a function to do the conversion and a mapping that triggers it. Simply place your cursor on the ISBN-10 and press Alt+i to replace it with its ...
Tumbler41's user avatar
  • 7,776
4 votes
Accepted

Why does my colorscheme not look like it should?

The problem with the specific macvim-light colour scheme you link to is that it has incredibly limited support for terminals: the only syntax groups it adds highlighting for are Normal, DiffAdd, ...
Rich's user avatar
  • 32.4k

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