All Questions

Filter by
Sorted by
Tagged with
47
votes
1answer
5k views

Expand a visual selection in the other direction

Sometimes I have selected a visual selection with, for example, Vjjjjj, only to realize later that I should have started the selection one line higher. However, pressing k simply decreases the lower ...
29
votes
3answers
7k views

How to create my own autocomplete function?

How do I create my own list of auto-completion for certain filetypes? For example I would like css and html to autocomplete from the list of css classes in FontAwesome.
22
votes
5answers
12k views

Is it possible to pipe vim commands to vim?

I want to run the following shell. wea-this is the end of the second word | vim j exit 0 Which I had hoped would pipe the key strokes w (move forward a word) then e (end of the word) then a (append) ...
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?
21
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 '. ',...
45
votes
5answers
33k 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 ...
33
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 ==...
30
votes
7answers
11k 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
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 . '!'
20
votes
1answer
734 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 ...
30
votes
4answers
14k 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.
22
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 ...
15
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 ...
15
votes
5answers
763 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 ...
26
votes
1answer
8k 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
7k 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 ...
27
votes
2answers
8k views

How can I redefine plugin key mappings?

I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (<leader>cc) defined by the plugin for my own pursope, I'...
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
6k 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, ...
18
votes
3answers
396 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 ...
16
votes
3answers
14k 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 ...
16
votes
4answers
2k views

What is the rationale for \r and \n meaning different things in s command?

We all know that, when searching, \n is newline and \r is carriage return (^M), but when replacing \r is newline while \n is a null byte (^@). What is the origin of this asymmetry? Given that this ...
7
votes
2answers
1k 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 ...
1
vote
2answers
2k 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\+'...
24
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 ...
14
votes
1answer
2k 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 ...
10
votes
3answers
4k 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 ...
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 ...
7
votes
1answer
197 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
4answers
367 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 ...
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=...
3
votes
1answer
597 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 ...
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 ...
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 ...
0
votes
1answer
541 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
178 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
699 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
1k 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)...
4
votes
1answer
388 views

What's wrong with "terminal cd ." in vim 8.1?

terminal cd . results in following weird error in the terminal buffer: executing job failed: No such file or directory The same error appears for term_start('cd .'). It doesn't matter which directory ...
2
votes
2answers
594 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
273 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 ...
1
vote
1answer
153 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 ...

15 30 50 per page
1 2
3
4 5
28