Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

74 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. ...
user avatar
  • 1,534
72 votes
Accepted

Vim search replace all files in current (project) folder

There are several ways to do this. Inside Current Directory If you want to perform the search/replace in a project tree, you can use Vim's argument list. Simply open Vim and then use the :args ...
user avatar
  • 5,756
32 votes
Accepted

What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?

Some features that will only work with gVim: 24-bit color support out of the box (to get the same amount of colors in terminal vim, you have to try a little harder, see this and this). For true ...
20 votes
Accepted

Get the current window/buffer/tabpage in Vimscript

Well… it's just as simple in vimscript. Current window Python: current_win = vim.current.window Vimscript: let current_win = winnr() Current buffer Python: current_buff = vim.current.buffer ...
user avatar
  • 32.6k
20 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 ...
user avatar
  • 16.5k
12 votes
Accepted

Mouse wheel scrolling inserts characters

Ah, I found the culprit by bisecting my .vimrc file. I had mapped Escape in normal mode to clear search highlighting: " Clear highlighting on escape in normal mode nnoremap <esc> :noh<return&...
user avatar
  • 393
11 votes
Accepted

How to move cursor in a specific column

If you want to do it from the normal mode, just type: 15|. If you want to move to 15th column in 25th, type 25G15|. If you want to do it as a command you can type: :call cursor(25,15) but I think it ...
user avatar
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. ...
user avatar
  • 45.9k
10 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('...
user avatar
  • 12.6k
9 votes
Accepted

How can I disable all mouse functions in MacVim?

To disable all mouse functions, you can simply put this in your vimrc file: set mouse= For more, see :help 'mouse'.
user avatar
8 votes

Scrolling down multiple lines with Ctrl+e

You can use a count before Ctrl-E − 15<C-e> moves down 15 lines. Ctrl-D moves down half a screen by default, although the amount it moves can be configured via the "scroll" option. :help motion....
user avatar
7 votes
Accepted

MacVim thinks I have unmatching parentheses, until I place cursor over each parenthesis

I can reproduce the problem on my Linux system running Vim 7.4.729 as gvim. The problem appears to be the synchronizing of Vim's syntax highlighting engine. To save time, Vim doesn't always look at ...
user avatar
  • 5,854
7 votes

How to change Vim's :hardcopy printfont?

Instead of printing from Vim, you could instead generate an HTML file using :TOhtml. Then you can use CSS to set the font used for the HTML and print that.
user avatar
  • 10.3k
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
user avatar
  • 7,406
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 ...
user avatar
  • 6,320
7 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 ...
user avatar
  • 27.4k
7 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 ...
user avatar
  • 1,902
6 votes
Accepted

What's the point of :promptfind after all

:promptfind and related commands are useful for the easy mode (evim), which according to :help easy sets Vim up to work like most click-and-type editors. As Notepad has such a find dialog, and users ...
user avatar
  • 16.6k
6 votes

How to simply remove braces

Summary It's a bug and there's a patch (743). The bug affects both your examples, but you don't see it in one case because the character that is moved down is a (whitespace). The solution is to ...
user avatar
  • 3,119
6 votes

How to simply remove braces

Since you aren't asking for the cursor to be returned to its original position, [{x]}x does the job. It's 6 characters long with two presses of Shift but the principle is straightforward so it's easy ...
user avatar
6 votes

How to simply remove braces

Install the "surround" plugin. Then you can just do d s B . From the project page: Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides ...
user avatar
  • 340
6 votes

What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?

Some of us are stuck in Windows land, so the terminal options are less convenient. In Windows Explorer you can right-click a file and open it immediately with gVim. That's a lot easier and faster ...
user avatar
  • 687
6 votes

Scrolling down multiple lines with Ctrl+e

Ctrl+e takes count, so the quick and simple way is to create a normal mode mapping like the following: nnoremap <C-e> 10<C-e> This will simply do Ctrl+e 10 times. You can change the ...
user avatar
  • 875
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 :...
user avatar
  • 2,480
6 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 ...
user avatar
  • 1,253
5 votes

What additional features do gVim and/or MacVim offer compared to Vim inside a terminal emulator?

I just can talk about gVim. Besides basic differences, I found that using gVim help me a lot at the beginning to learn basic commands (for example one way of copying selected text to the clipboard ...
user avatar
5 votes
Accepted

E334: Menu not found: Window.Minimize

Important note As I mentioned it in the comments when you begin to use Vim the best you can do is to start with an emtpy .vimrc. From this you'll be able to build your own configuration which really ...
user avatar
  • 45.9k
5 votes
Accepted

How can I force a page break in MacVim's printed output?

From :help popt-option: formfeed:y When a form feed character is encountered, continue printing of the current line at the beginning of the first line on a new page. So… ...
user avatar
  • 32.6k
5 votes
Accepted

Repeating the last move using . (w followed by .)

As stated in :h . the dot command only repeat changes, but commands like w are motions not changes. You can repeat motions like f, F, t and T with the commands ; and g; (see :h ;). And for more ...
user avatar
  • 45.9k

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