All Questions

Filter by
Sorted by
Tagged with
38
votes
2answers
5k views

What is <Leader>?

I see <Leader> quite often in other people's vimrc files. Like this one. What is it? What does it do?
20
votes
3answers
2k views

The simplest way to start Vim in private mode

I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands: set history=0 set nobackup set nomodeline set noshelltemp set ...
19
votes
4answers
3k views

How to set up Vim to work with one sentence per line?

I'm currently writing a lot of plain text (and LaTeX with minimal formatting in paragraphs), and it would be nice if I could set up vim to keep each sentence (for simplicity, text terminated by a '. ',...
40
votes
5answers
30k views

How can I open very large files with good performance?

I have server log files that are several gigabytes in size (on Ubuntu). When I attempt to open them, the terminal locks up for a minute or so while the file is loaded into Vim. Is there a way to ...
32
votes
2answers
11k views

Extract the result of a shell command to a variable in a .vimrc file?

In my .vimrc file, I would like to store in a variable the result of an external command, in my case: $ echo $LANG So that my .vimrc file would have : let language = output(!echo $LANG) if language ==...
29
votes
7answers
9k views

Faster way to move a block of text

Here's how I usually copy a block of text or code: Select the block with Visual mode (V) and delete it with d; or if it's just a single line, just use dd. Go to where I want the text to be, I am too ...
20
votes
1answer
682 views

How do I enable language-specific syntax inside a heredoc?

When I edit a PHP file and I define a string in a heredoc, syntax highlighting will be enabled inside the heredoc if it is JavaScript syntax or HTML syntax or SQL syntax. However it will not work for ...
29
votes
4answers
12k views

How do I center the current line in the screen?

Is there a way to center the line I'm editing in the screen? This is sometimes needed to see a bit more context above and below the current line.
21
votes
4answers
21k views

How can I install 64-bit Vim on Windows?

Vim's Downloads page says the 64-bit version is discontinued: Win64 The 32-bit version of Vim runs fine on 64-bit windows. There was a 64-bit binary, but it wasn't used much and maintenance ...
19
votes
1answer
3k views

What is the difference between single and double quoted strings?

What is the difference between single and double quoted strings? Is there a way to get a variable expanded inside a string, or do they always need to be joined like: 'Hello, ' . s:name . '!'
15
votes
5answers
736 views

Can I be notified when I'm undoing changes from the undofile?

I've been using the undofile feature in Vim for a while now. It's a very nice feature. However, one annoyance is that it's very easy to accidentally undo changes that I did the last time I opened the ...
14
votes
2answers
3k views

How to repeat a mapping when keeping key pressed

I have in my .vimrc some simple mappings to resize split windows easily: noremap <Leader><UP> <C-w>+ noremap <Leader><DOWN> <C-w>- That works pretty fine but ...
25
votes
1answer
7k views

Understanding CTRL-U combination

In this answer I faced the CTRL-U used in function call after : and before the actual function name. :nnoremap <buffer> <cr> :<C-U>call append('.', repeat([''],v:count1))<cr> ...
19
votes
5answers
6k views

Vim syntax pattern to highlight python keyword argument

I'm struggling with learning vim regexps (I don't know any other regexp very well either), so the main problem is to define regexp that would match some_function_call(simple_value, keyword=value) ...
10
votes
5answers
2k views

How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?

When I want to edit my zshrc, I just type: vim .zshrc Without specifying the full path (~/.zshrc), if I am in a different directory, this will instead start a new file. This is very annoying, since ...
19
votes
2answers
2k views

What is the difference between set and :set (commands with or without a leading colon)?

I was looking at Tim Pope's vim-sensible plugin and I noticed this in the README... See the source for the authoritative list of features. (Don't worry, it's mostly :set calls.) When I looked at ...
16
votes
2answers
4k views

Can I save folds?

Today I learned how to fold/unfold in Vim; it's quite handy. Unexpectedly, when I exit a file and reenter it, the folds I created are gone (unfolded). In our company's large project there are ...
9
votes
5answers
5k views

Vimscript - Surround word under cursor with quotes

I'm writing a Vim plugin which will need to surround the word directly under your cursor with a quotes. I have tried using simple solutions which use commands like "b" and "e" executed in normal mode, ...
7
votes
4answers
3k views

How to convert all windows into horizontal, vertical or tab splits?

It is possible to convert all windows into different split mode while editing? Instead of one by one? In example (having multiple windows) from horizontal to vertical split and opposite, or from tab ...
18
votes
3answers
379 views

What is the '[Command Line]' that sometimes comes up when I try to quit, and how can I quickly exit it?

Occasionally when I try to quit Vim, I get something that looks like this: I'm not sure how I accidentally invoke this, but my current method for escaping it is to hit random keys and eventually it ...
16
votes
2answers
3k views

Tmux is changing part of the background in vim

This only seems to happens when using vim inside of tmux. I'm also using iTerm 2. If I create a new tmux pane or resize a tmux pane, it immediately looks like the this: And then the only way to fix ...
15
votes
3answers
13k views

vim doesn't show the command that is being typed

I was reading vimtutor and in lesson 2.1 there was this note about typing commands like dw: NOTE: The letter d will appear on the last line of the screen as you type it. Vim is waiting for you ...
6
votes
2answers
992 views

How do I run a command on creation of a new file?

I'm aiming to make scripts I write in a certain directory (or of a certain extension) automatically executable on creation. I can do this whenever a file is written to, using the following autocmd: ...
2
votes
2answers
4k views

How to use WSL's bash shell as default terminal of gvim/windows 10?

gvim 8 1-26 / windows 10 I'd like to use Windows Subsystem Linux (WSL)'s bash shell as a gvim's terminal instead of cmd. So if I type in command potion of gvim: :!.\test.sh, it will echo result ...
23
votes
4answers
7k views

Automatically load Vi into insert mode

I use Vi as my preferred (and, in fact, only) text editor on Linux Systems. I know how to change modes from normal to insert, and vice-versa. Is it possible to have Vi automatically load into Insert ...
13
votes
1answer
1k views

What bad things can happen if I use :bwipeout?

I have just discovered the :bwipeout command, for which the :help states: Like :bdelete, but really delete the buffer. Everything related to the buffer is lost. All marks in this buffer ...
13
votes
3answers
3k views

How can I prevent Vim from leaving too many files (like swap, backup, undo)?

By default, vim leaves swap files in my project directory, and on crashes it leaves backup files. Can I prevent this? Or do I need to update all my projects' .VCSignore file?
11
votes
4answers
3k views

How to achieve selection different length of texts on different lines?

assume I have following texts: aaa-dd-e: "aaa", bb-x: "bb", c-9: "c" I want to do selection like below: aaa-dd-e: "aaa", bb-x: "bb", c-9: "c" I tried using c-v to create a visual block, but after ...
9
votes
2answers
1k views

How do I prevent Vim from unindenting empty lines?

Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret. Caret is indented and I press enter if expression: ...
9
votes
2answers
6k views

How to make vimrc settings applicable for a directory tree only [duplicate]

Is there a way to make certain vimrc configuration valid only for files under a defined directory tree? Or alternatively, is there a way to have a .vimrc file in a directory, and make its setting ...
9
votes
3answers
3k views

Why does !cd not change the directory

I'm going through vimtutor and just learned about using :!<CMD> to execute a shell command from within vim. I read a bit up on why not to use just :<CMD> and apparently it's because some ...
7
votes
1answer
183 views

Difference between `:!{cmd}` and `:w !{cmd}` regarding alternate screen

On a Linux platform I see this difference of behavior between running a shell command with :!{cmd} (which just runs the command directly) and with :w !{cmd} (which passes the buffer as standard input ...
5
votes
1answer
1k views

How to show all unique types of a pattern?

I have a very large file containing about, for example, 5 million lines like this: Songs=****, Singers=**** Singers=*** Songs=*** .... # many many lines SongType=*** ... # many many lines again Album=...
4
votes
4answers
300 views

Can I use a different color for the selected match than for other matches [duplicate]

In the screencast below I searched statusline and then cycle through the results with n. Is it possible to highlight the selected match with a different color than the other matches, instead of ...
3
votes
1answer
1k views

Fire autocmd FileType on current buffers in windows

Context I have shortcuts to edit my vimrc and to source my vimrc. When I'm writing code I can quickly add a new mapping and then source vimrc. And all that would be good if I did not use autocmd ...
3
votes
1answer
271 views

Vim on Debian, configuration issues

I have been working with a stock vim configuration for a long time. I want to modify just a couple of settings. I don't want to lose the rest of the default configuration. If I create a new .vimrc I ...
2
votes
2answers
1k views

Auto back-indent word 'else' in if/else statement in Vim

There is this feature or module in Vim which auto back-indents words during writing if/else statements. For example: if a == 1: xx <-- here when I press enter cursor goes right below end of ...
1
vote
2answers
1k views

Interactively check given string highlight group

We can get highlight group information by the following command :hi[ghlight] {group-name} But is it possible to get this information by given keyword? Something like this : syn match Integer '\d\+'...
0
votes
1answer
532 views

Quickest navigation within a buffer [closed]

Okay, here's the thing: let's say you have a buffer, 1000 lines long (a source code for example). And you want a super-fast navigation, jumping to the right place. Example: You are on a line 42, on ...
7
votes
2answers
175 views

a highlight command resets previously declared highlights

I'm trying to tune the highlighting in my vim and I'm trying to set some syntax groups via the match command and highlight them in my vimrc file, because those groups are generic and do not belong to ...
7
votes
1answer
682 views

Vim 8 packages, how do I overwrite a default package?

I have installed Dr. Chip's netrw from his homepage, since it is newer and more often updated than the files that are part of the main Vim distribution. Before Vim 8 I always sued the Vimball install ...
5
votes
1answer
975 views

Can Vim add to the X11 clipboard or primary buffers without an external utility?

We can copy to both the + and * registers, but this doesn't actually copy the content to X's memory (apparently). If you copy something from Vim using the * or + registers and quit Vim, poof! There's ...
4
votes
1answer
2k views

How to set a local variable for a plugin in a BufNewFile autocmd

I currently have autocmd BufRead *.sage \ set filetype=python | \ let b:syntastic_skip_checks=1 which works as intended (sage files are treated as Python, but with Syntastic disabled)...
2
votes
2answers
552 views

Move to the first/last non-whitespace character of the column (“vertical W/B/E”)

For instance move from (the cursor is on the letter in bold italic, in the second column) blablabla blablabla blablabla blablabla bla bla bla bLablabla l@st to blablabla blablabla blablabla ...
2
votes
2answers
264 views

Repeat complicated motions

I know that similar things were asked here several times. I know that to repeat a motion ; works. Unless it doesn't(in case there is count for example), but then repmo.vim usually works. And I know ...
2
votes
1answer
474 views

How to navigate long lines like separate lines?

When I have a very long line in vim it will be shown on the screen as multiple lines, like this: line no. | content | 100 | this is a very ...
1
vote
1answer
143 views

Filter file completion list

When I write markdown and want to insert an image, i_CTRL-X_CTRL-F comes in handy. I know that I can filter by typing a few characters that precede the filename, but actually what I want is either ...
199
votes
4answers
161k views

Why doesn't the backspace key work in insert mode?

Trying to delete characters in insert mode with the backspace key sometimes doesn't seem to work. I can backspace sometimes, but at other times it does nothing; the cursor doesn't go to the left, and ...
109
votes
16answers
91k views

How do I delete a large block of text without counting the lines?

In vim, I often need to delete, or yank/put large blocks of text. I can count the lines of text and enter something like 50dd to delete 50 lines. But that's a bit of a pain. How can I delete this ...
110
votes
16answers
110k views

Other ways to exit Insert mode besides Escape

The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, ...

15 30 50 per page
1 2
3
4 5
27