91
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. ...
26
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
...
21
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 ...
12
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 ...
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&...
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('...
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. ...
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'.
8
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.
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....
7
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 ...
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
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 ...
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 ...
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 ...
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 ...
6
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 ...
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 :...
6
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:
...
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…
...
5
votes
Accepted
Going back to the [n] last edited position
What you want is the "changelist": :help changelist.
Use 3g; to jump to the third previous change in the "changelist" and 2g, to jump back 2 steps in the list.
5
votes
Scrolling down multiple lines with Ctrl+e
As others have noted, you can prefix both <C-e> and <C-y> with counts, to "expose" that many more lines up or down.
Another handy quick scrolling option lets you scroll so that the ...
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 ...
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. ...
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 ...
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 ...
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 ...
4
votes
Accepted
How can I drag a file onto MacVim and make it open in a split, not a new tab?
The "Open files from applications" preference in the General preference pane
gives more options on how dropped files should open, in case tabs are not
desired. See :h macvim-drag-n-drop.
After ...
4
votes
Accepted
Vundle/vim can't see changes in .vimrc
Vim parses your .vimrc once when it is started. Whenever you change something in it (in your case add a new plugin), vim needs to be told manually that something changed so that the .vimrc gets parsed ...
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. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
macvim × 151vimrc × 32
macos × 21
gvim × 16
vimscript × 11
key-bindings × 10
terminal × 9
neovim × 6
plugin-you-complete-me × 6
iterm2 × 6
tabbed-user-interface × 5
syntax-highlighting × 4
cut-copy-paste × 4
vim-windows × 4
plugin-ultisnips × 4
font × 4
printing × 4
cursor-movement × 3
scrolling × 3
bash × 3
search × 2
autocompletion × 2
colorscheme × 2
cursor-motions × 2
netrw × 2