jamessan
  • Member for 6 years, 11 months
  • Last seen more than a month ago
Does Ex mode have any practical use?
Accepted answer
126 votes

Q is, as you found, ex mode. It's not entirely useful to use interactively, but it exists because Vim can be used to emulate the old ex binary. In fact, many systems provide the ex command by simply ...

View answer
What is the purpose of swap files?
Accepted answer
120 votes

Reasons for swap files Swap files store changes you've made to the buffer. If Vim or your computer crashes, they allow you to recover those changes. Swap files also provide a way to avoid multiple ...

View answer
How do I center the current line in the screen?
Accepted answer
48 votes

The z. and zz commands will recenter the line the cursor is on. z. also moves the cursor to the first non-whitespace character in the line, while zz keeps the cursor where it is. There are similar ...

View answer
Is it possible to make Vim auto-save files?
Accepted answer
38 votes

There isn't a builtin option, although :help 'autosave' (in todo.txt) refers to a description of what such an option could do. One possible way to implement this is to use the CursorHold autocommand ...

View answer
What does z stand for in vim?
Accepted answer
33 votes

z doesn't stand for anything. g and z were two letters that went unused as standalone commands (z<CR>, z., z+, z-, and z^ existed) in vi, so they have been repurposed in Vim as a prefix for a ...

View answer
How do I visually select the block of text I just pasted in Vim?
Accepted answer
24 votes

The '[ and '] marks delimit the first and last line of the previously changed or yanked text. The `[ and `] counterparts delimit the respective lines & columns. Using that, you could visually ...

View answer
Why did p paste a copied line after the current line, instead of after the current word?
Accepted answer
22 votes

When you deleted the line using dd, you performed a linewise delete. The p command pastes after the cursor position. Since the default register was populated with linewise content, that means it ...

View answer
Re-indenting badly indented code
19 votes

The = command can be used to reindent. Like most normal mode commands it can be applied to a motion, so you can reindent the just pasted code with =']. This reindents from the current cursor ...

View answer
Cut vim load time
Accepted answer
18 votes

If you just want to see what's consuming start up time, then you can use the --startuptime option. vim --startuptime timing.out The file will look like this: times in msec clock self+sourced ...

View answer
How do I get Vim to be able to run both python and python3 on a Linux system in the same session?
17 votes

I'm the current Vim maintainer for Debian and the person quoted in the referenced mailing list discussion. As you stated, this isn't a question about Vim. It's about building the software that Vim ...

View answer
How to tell vim not to try to unzip a file
Accepted answer
17 votes

Functionality like this is handled by autocmds. In order to disable autocmds for a specific command, you can use :noautocmd (abbreviated :noau). In this case :noau e foo.xlsx will simply open the ...

View answer
How can I prevent Vim from leaving too many files (like swap, backup, undo)?
Accepted answer
16 votes

Backup files By default, Vim doesn't leave backup files behind. They are merely transient files that exist while Vim is saving the buffer to disk. As described in :help backup-table this behavior ...

View answer
When should I use vim-addon-manager instead of a regular package manager?
Accepted answer
15 votes

N.B., I'm one of the original authors of Debian's vim-addon-manager (which I'll refer to as dvam for the rest of this answer, to avoid confusion with Marc Weber's vam). dvam is intended solely to ...

View answer
How do I keep accidentally creating a no break space before opening curly brace?
15 votes

The 'listchars' option provides a means to make 'list' display non-breaking spaces. It's not set by default, so you probably want to add it. set listchars+=nbsp:‗

View answer
Is there any way to distinguish between neovim and regular vim?
Accepted answer
14 votes

Use if has('nvim') to detect if you're running Neovim. Note that, unlike Vim, Neovim doesn't have the language bindings built in. They're provided by external plugins. You would need to install the ...

View answer
How to install pathogen on Neovim?
Accepted answer
14 votes

mkdir -p ~/.vim/autoload ~/.local/share/nvim/bundle This is wrong for Neovim. ~/.config/nvim is the replacement for ~/.vim. mkdir -p ~/.config/nvim/autoload ~/.config/nvim/bundle is what you should ...

View answer
What is the rationale for \r and \n meaning different things in s command?
Accepted answer
13 votes

At the most basic level, there's already an asymmetry between the search and replace portions of :substitute because the former is a regular expression and the latter is text, with specific additional ...

View answer
Can Vim add to the X11 clipboard or primary buffers without an external utility?
13 votes

TL;DR: This isn't really possible without a clipboard manager (e.g. clipit, diodon, glipper, parcellite). It's an explicit design choice of X to not store the data for the X selections, whether that'...

View answer
Do VimScript functions have to start with a capital letter and if so, why?
Accepted answer
12 votes

To quote :help user-functions The function name must start with an uppercase letter, to avoid confusion with builtin functions. The same restriction is placed on user-defined commands, although ...

View answer
How can I open a buffer in a new tab leaving the current window and buffer intact?
11 votes

:tab split will create a new tab displaying the current buffer, since :tab modifies any command that would normally create a split to instead create a tab page. If you want to override <C-w>T ...

View answer
Filetype that LaTeX should be
Accepted answer
11 votes

When there's not enough information to decide otherwise, 'filetype' is set to the most basic -- plaintex. Your existing file must have had enough content for the detection to determine that it was ...

View answer
Move to non-existing Nth column
Accepted answer
10 votes

You can use 'virtualedit' to allow moving to columns that don't contain text. If you set virtualedit=all, then 80| will place the cursor on column 80. No spaces will be inserted until you actually ...

View answer
What is the easiest way to insert en dash in Vim?
10 votes

If there isn't a predefined digraph or you want a more memorable key sequence, then you can define digraphs in your vimrc. For example, the below will define two digraphs for en dash (8211) and em ...

View answer
Why can ci" be outside of quoted area and ci( only works inside parentheses?
10 votes

The quote family of text objects (i', i", a', and a") are different than the rest of the text objects in that they only look at the current line. Due to this, the choice was made not to require the ...

View answer
Are the internal g:, b:, w:, etc dictionaries documented?
Accepted answer
9 votes

Poking around with :helpgrep \<g:\A, I found this is documented under :help internal-variables: There are several name spaces for variables. Which one is to be used is specified by what is ...

View answer
Neovim setup on MS Windows
Accepted answer
9 votes

The user's runtime directory is $XDG_CONFIG_HOME/nvim. When $XDG_CONFIG_HOME isn't set (which is the typical case), then the default directory is ~/AppData/Local on Windows and ~/.config elsewhere. ...

View answer
What is an exhaustive list of "all the things" in vim?
Accepted answer
9 votes

Vim has a user manual (:help usr_toc) that covers all of these topics. It's good to browse through in general and can be a good starting point when you're thinking How do I do X in Vim?. Opening up ...

View answer
Prevent 'Press ENTER' when pathogen loads but keep for other scripts
Accepted answer
9 votes

Change the call pathogen#runtime_append_all_bundles() line in your vimrc to call pathogen#infect(), as the message suggests.

View answer
Quickfix support for Python tracebacks
Accepted answer
8 votes

Vim comes with a set of "compiler" scripts, one of which is called "pyunit". If you run :compiler pyunit and then :make (with your suggested value for 'makeprg'), quickfix is ...

View answer
How do I turn off the "feature" where the pound sign "#" is forced to 0 position?
Accepted answer
8 votes

As documented in :help 'smartindent' When typing '#' as the first character in a new line, the indent for that line is removed, the '#' is put in the first column. The indent is restored for the ...

View answer