All Questions

Filter by
Sorted by
Tagged with
5
votes
1answer
74 views

How do I get rid of <filename>.project.vim files?

It seems like any time I edit a file with gvim it creates a litany of files I don't want or seem to need. I understand the <filename>.~ files are backups of the file before I started editing and ...
14
votes
3answers
2k views

How can I clear a register/multiple registers completely?

I quite often use the :registers command to show the contents of all the registers (I forget what I put where, exactly what the role of "*, "., "%, etc. are). Especially because I set the " option in ...
26
votes
4answers
4k views

Renumbering buffer list

After I've been working on a project for a while, I start to see large gaps between consecutive buffer numbers. This is because the buffers in between them were wiped out for various reasons. ...
3
votes
1answer
97 views

Can I open a group of buffers at once? [duplicate]

When I need to reopen vim for some reason (vim updated, reboot, etc), I need to manually open a bunch of buffers when I start up. Is there some way I can save the current set of buffers open in some ...
17
votes
2answers
7k views

How can I reload all buffers at once?

When working on a feature branch in git, I frequently need to stash my changes to commit a bug fix to the main branch. When I'm done working on the changes, I git stash pop, which updates the ...
114
votes
7answers
35k views

Does Ex mode have any practical use?

Vim has an Ex mode that can be entered by entering Q, and a command line mode that can be entered with q:. A common complaint amongst new vim users is that they enter these modes accidentally when ...
138
votes
5answers
87k views

What's the simplest way to strip trailing whitespace from all lines in a file?

It's pretty common when programming or opening text files to encounter files with trailing whitespace at the end of a line. vim has a way to show this by setting the trail option in the listchars ...
134
votes
5answers
68k views

How do I reload the current file?

Quite often I am working with files that are version controlled, so it is possible for changes to be made to them outside of Vim. What is a quick way to reload the file without having to close and ...
4
votes
2answers
123 views

How to paste and remove current line

For example if I copy several lines of text and open a brand new file. If I paste with p, then I get an empty line above the pasted text, and if I paste with P, I get an empty line below the pasted ...
69
votes
4answers
13k views

How to join lines without producing a space?

The standard J command for joining lines replaces the newline character(s) with a space. It's useful when editing 'literature' but can be troublesome if I, say, edit a hex dump by hand if I forget to ...
10
votes
3answers
106 views

Shadowed terms in help

Occasionally, when I'm searching the help system for a particular topic, it will be shadowed by a different topic. For example, if I do :h display I get help for something involving "GUI Resources", ...
1
vote
1answer
112 views

Get name of nearest tag to the cursor

When I write an answer on this site, I often want to link to a part of Vim's :help pages; http://vimhelp.appspot.com/ has an online version of that. However, I'm too lazy to manually lookup the page ...
11
votes
2answers
3k views

Prevent Vim from clearing the terminal after exit

If I do: $ less file And press q to exit less, I stil see the same text as I had on the screen when less was still running. However, if I do $ vim file And :q, my terminal is blanked... ...
30
votes
1answer
3k 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 ...
115
votes
6answers
110k views

Displaying tabs as characters

When I work on files in python, I sometimes mistake tabs for spaces and vice versa. Is there a way I can get Vim to display a character for a tab instead of a tab?
9
votes
4answers
2k views

Adding 80-column wide comment header block with centered text

For some reason or another I often divide the code into subsections separated by headers like these: ################################################################################ ##################...
12
votes
3answers
324 views

UI to personalize a vimrc without writing one from scratch

Vim is so infinitely configurable. However, devising a vimrc is a daunting task for novices and intermediate users. Basically, you're expected to develop one from a blank slate by reading the ...
30
votes
4answers
2k views

Terminal borked after invoking Vim with xargs

I've sometimes tried invoking Vim using xargs, like this: find . -name '*.java' | xargs vim … which kind of works: As Vim launches, I see the following warning flash briefly: Vim: Warning: Input ...
3
votes
4answers
490 views

Can Escape be disabled in insert mode?

I'm trying to retrain my fingers to refrain from using Escape so often. Can I disable Escape when I'm in insert mode, leaving just Control+[ and Control+C as the only ways to return to normal mode? ...
3
votes
1answer
590 views

What are the Control-key combinations/chords?

Because of Vim's modes, there is not a lot of holding down the Ctrl key while pressing another key. However ,in insert (or replace) mode, Ctrl+R will let you paste a register, and Ctrl+V lets you ...
12
votes
1answer
876 views

How to underline titles? (reStructuredText, Markdown, asciidoc style)

Various plain-text markup languages: reStructuredText, Markdown, asciidoc (others too), use an underline to denote titles. Chapter 1 Title =============== Section 1.1 Title ----------------- ...
6
votes
0answers
799 views

Resources for scripting vim with python [closed]

I love vim, I love python, and I dislike vimscript. So I would like to know how to write plugins (or throwaway scripts) for vim in python. Of course, the first reference should be :h python, but I ...
13
votes
1answer
876 views

Can vim syntax regions be made to touch/overlap?

So a while ago I had decided to learn more about how vim's syntax files work, by creating my own. My goal was to create a simple syntax file that would split the file into 3 parts based on delimiters,...
6
votes
1answer
984 views

Altering HTML templates in vimwiki

The vimwiki plugin offers a great feature of converting whole Wiki to HTML: :VimwikiAll2HTML. But it bothers me that there are no back links to the main page, and the only way to navigate back to the ...
194
votes
10answers
86k views

What is the difference between the vim plugin managers?

I have been looking at the different package managers for vim and the one I decided to use vim-plug but I have seen others like pathogen and vundle and I honestly don't know what the difference is. ...
10
votes
1answer
94 views

Is there a <C-w> for WORDs?

Pressing Ctrl-w in Insert mode will delete the previous word. It is equivalent to Ctrl-Backspace in Windows, and Opt-Delete in OS X, and really speeds up typing. Vim has the separate concepts of word ...
12
votes
7answers
2k views

Can vim automatically turn off Capslock when returning to normal mode?

After almost every time I type something in caps, I forget to turn off capslock when returning to normal mode. I then try to move the cursor and end up joining a bunch of lines and a lot of other ...
14
votes
4answers
5k views

Can I do an interactive :substitute (search & replace)?

Sometimes I use :s with a complicated regexp which may or may not be correct, or aren't sure if I want to replace all matches. Is there any way I can tell Vim to confirm every match it finds before ...
6
votes
2answers
96 views

How do I detect I've entered a wrong password when using cryptmethod (and make Vim ask for it again)?

If I encrypt a file with :set cryptmethod=blowfish or :set cryptmethod=blowfish2, and open the file in Vim, it asks for my password on startup. I type in the correct password and continue happily. ...
20
votes
2answers
2k views

Is it possible to use two different color backgrounds in a single vim buffer?

I am looking for a possible solution for applying two different background colors inside a single vim buffer depending on context like in this sublime text example. One use case of that is to color ...
14
votes
1answer
4k views

How secure is encrypting files with blowfish?

I know using :set cryptmethod=zip is not secure, but how secure is using :set cryptmethod=blowfish? On wikipedia I read that the blowfish cipher, as such, should be secure, but this says nothing ...
26
votes
4answers
8k views

How can I easily create and maintain tables?

Here is (part of) a table I use in some documentation: +---------------+------------------------+---------------------------------------+ | TASK NAME | WHEN | DESCRIPTION ...
13
votes
1answer
532 views

How is command history resolved between multiple instances of Vim?

Vim keeps a history of ex commands (accessible via :↑ and q:), and that history persists after quitting. If I run multiple instances of Vim (same user, same home directory), how does Vim arbitrate ...
21
votes
8answers
5k views

How to “full screen” browse Vim help?

I know I can browse Vim help with :help, but this opens a split. Sometimes, I just like to study documentation. How read documentation in a "full screen" mode?
47
votes
3answers
26k views

How can I set up a ruler at a specific column?

When coding in different languages, I tend to need to restrict my lines to a specific length (usually 79 or 80 characters). I've seen this done in other editors through the use of a ruler (solid line ...
10
votes
1answer
559 views

Incorrectly indents JavaScript chain calls

For example, if I have some JavaScript code like this: var widget = library() .chainCall1() .chainCall2() .chainCall3(); If I use the = command to auto indent it, it comes out looking this ...
77
votes
5answers
61k views

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
10
votes
1answer
451 views

Multiple buffers, same file, different settings

Is it possible to edit a file under different settings at the same time? More precisely, I'd like to have multiple buffers in the same instance of Vim which have the same content (changing one buffer ...
17
votes
2answers
3k views

What is the relation between vi, nvi and vim?

On some unixes sometime I found a command named nvi. It was a vi-like editor, without much of its functionality. Maybe it was a fork of the old vi? Anyways, which vi versions are a fork of the others,...
10
votes
3answers
1k views

How can I use my trackpad for horizontal scrolling?

I just noticed that my trackpad scroll works in Vim, inertia and all. I'd like to change this to work horizontally - so I can scroll up and down to make the cursor move left-and-right instead of ...
8
votes
7answers
2k views

Does Vim have any hidden “easter eggs” or jokes? If so, which? [closed]

I've heard rumours about Vim having some hidden "easter eggs" and jokes. Is this true? What are they?
9
votes
1answer
2k views

Define custom commands for the * and + registers

If I'm using a build of Vim with the xterm_clipboard feature then the system clipboard content is available through the + register. If the build I'm using doesn't have this feature, can I make the "+ ...
0
votes
2answers
1k views

How can I comment code with a command in Vim [duplicate]

In various editors one can mark a block of code and with a shortcut, comment it right away. Is there a possible way to do it in Vim without an extra plugin? If not, which plugin or script would you ...
16
votes
4answers
519 views

Set the paste option, but for one insertion only

I want to have a quick way of setting the Vim 'paste' option, inserting some text, and reverting to the previous value of 'paste'. A typical use case insert the OS clipboard content literally, ...
3
votes
2answers
628 views

What types of buffers are there?

Many answers make reference to a "paste buffer" or a "search buffer". Can someone provide a quick primer on what types of buffer there are? Are they interchangeable? Or is it something different?
2
votes
1answer
869 views

Autocommand groups syntax and usage [closed]

What are some of the ways to construct autocommand groups in the .vimrc? What is the benefit of grouping autocommands? Can you provide some materials on proper use of autocommand groups? Any help here ...
22
votes
4answers
3k views

How to use an external command in Vim to modify selected words and lines?

Something I've found useful in other editors is the ability to: take the selected text run an external command and pass the selection to its stdin take the external commands stdout and replace the ...
20
votes
2answers
2k views

Can I open a file in an existing Vim instance from an external command?

Some applications have the notion of a "session", where you can run a command to load a file in an existing instance of an application. For example, when I type: $ firefox http://vi.stackexchange....
10
votes
2answers
418 views

How do I make opening new tabs the default?

When I open vim with multiple files (vim f1 f2 ...), how can I make it open them in tabs directly, without using -p? I'm looking to separate out shell behaviour from vim behaviour, removing vim-based ...
9
votes
1answer
446 views

Regex that prefers shorter matches within a match? (This is more involved than non-greedy)

I'm trying to create a script for performing fuzzy search inside a buffer. The main idea is to take some input, and insert .\{-} between every pair of characters, e.g. foo becomes f.\{-}o.\{-}o. This ...

15 30 50 per page