All Questions

Filter by
Sorted by
Tagged with
8
votes
1answer
353 views

Run shell commands on current file based on file extension

I'm currently doing a lot of work with both Ruby and JavaScript. I know that I can run my Ruby files with :! ruby % and likewise my JavaScript with :! node %, and that I can bind either of those to, ...
21
votes
5answers
1k views

GitHub for .vimrc and plugins

I know many people store their .vimrc on GitHub to make it easier to get right to work on new machines, and that makes complete sense to me. Including plugins, however, is problematic, because the ...
7
votes
2answers
1k views

Creating & maintaining flowcharts in Vim

Here is a simple text-based flowchart I made in Vim for a weblog post: [DNS request] | | [Adsuck] | ...
9
votes
2answers
2k views

Folding fails: vim can't find any fold

I'm trying to fold some PHP code, and I have included a cut-down version of some of the code I'm trying to fold at the end of the post. I've tried the following vim commands, but only the ex commands ...
6
votes
1answer
59 views

Is there any way to add to the help system without developing a plugin

I have somewhat customised vim to my needs what I would like to do would be to add a cheatsheet, documenting these customisations and other things I often forget to the vim help system. I know that ...
5
votes
4answers
236 views

Move vertically to a specific character on a different line

It is easy to move to a specific character on the same line with t or f. However often it is useful to move to the specific character that is positioned on a different line. Consider this example: ...
4
votes
1answer
69 views

Can the command-line window be entered without interrupting macro recording?

I'm having a problem using the command-line window (help cmdwin), which is extremely useful, but it doesn't play well with macros. cmdwin is invoked with q:, so if there is a macro being recorded, ...
9
votes
1answer
116 views

Can I force parentheses matching to show up across multiple windows?

I have a source file containing a long list of deeply nested heterogenous structures. Since the structures are long, I would like to: Use the :split command to split the screen into two. Scroll down ...
111
votes
6answers
60k views

How do I change the current split's width and height?

I am working on split (using ^w+v, ^w+s) buffers, but sometimes I would like to widen a current split or change its height. How can I achieve that?
16
votes
3answers
11k views

Can I issue an interactive shell in Vim window?

I know I can :! or :r! to execute external command and optionally insert its output into text. I can even perform :!sh and I'll spawn a shell that will live until I exit it - but while the shell is ...
36
votes
6answers
12k views

Can I justify text in Vim?

The only reason why I'd ever edit a text file in Pico or Nano, and not in Vim was its "Justify" command ^J. It would reformat a paragraph of text, creating line breaks at word breaks so that the text ...
9
votes
1answer
89 views

How can I easily get the length of a piece of text?

I sometimes want to check the length of a piece of text, for example in this example: str = 'Hello, world!' if len(str) == 13: print('Hello back to you!') I would like to know the length of the ...
4
votes
0answers
89 views

Return to previous buffer without going through every jumplist entry [duplicate]

When I've jumped from a buffer to another buffer I use C-o to return and after that I use C-i if I want to jump to that same buffer again. I think this is the common approach. The problem is that this ...
11
votes
5answers
849 views

Navigating multiple files

If I open vim with multiple files on the command line, for example vim debug.log* which loads debug.log, debug.log.1 and debug.log.2, can I navigate between them, assign them to multiple windows (:...
17
votes
1answer
3k views

More detailed comparison within a line

I use vimdiff to inspect differences between files, and some times it misses out a bit. for example, if I have the following two files: //a.c printf("Hello\n"); and: //b.c int i = printf("hello\n") ...
85
votes
5answers
67k views

How to replace tabs with spaces?

Is it possible to convert tabs to spaces, while maintaining text alignment? Simply replacing only works usefully when there are no leading characters.
10
votes
2answers
3k views

How do I install a .vimball Plugin?

I was given a plugin for Vim. It came in something called a .vimball. What am I meant to do with this exactly? Where do I put it? Do I need to be root to install it?
20
votes
1answer
497 views

Why aren't Vimballs commonly used?

I have seen that a lot of Vim Plug-ins don't seem to have Vimballs. Vimballs were/are basically a tarball for a plugin that vim knows how to install. They were/are thus slightly more convenient that ...
6
votes
3answers
5k views

How do I break a file into two?

I am writing some documentation (a user guide), in markdown in Vim. I now realise what I though should be one page, really should be 2. But I've already written alot of of both halves How can I ...
29
votes
2answers
6k views

Can Vim interpret terminal color escape codes?

Many CLI programs output nicely-highlighted text. While most of them check if the output is going to a file, some include the terminal escape codes. I like the output with the escape codes, but ...
10
votes
2answers
1k views

Automatically creating functions out of function prototypes from header files

Intro When programming in C and C++ you usually split your function prototypes and actual functions into a .h/.hpp and .c/.cpp file. Sadly it's very tedious to transfer the function prototypes from ...
6
votes
1answer
353 views

Correct all spelling mistakes in the document

I've turned on spellcheck with :set spell spelllang=en_us. Now there's a bunch of words highlighted in red, and I just want to correct them all to their closest matches. How can I correct all ...
11
votes
2answers
3k views

How do you fold functions automatically?

Is there a way to make Vim fold functions based on the syntax of a function declaration? For example having vim turn a function like this: def foobar(foo,bar): if foo > bar: print "foo" ...
8
votes
1answer
179 views

Running cleanup commands only for edited lines possible?

Referring to clean-up tasks like (but not limited to) the ones detailed in these questions: Re-indenting badly indented code What's the simplest way to strip trailing whitespace from all lines in ...
26
votes
2answers
2k views

How to save a file for which I have no write permissions?

Sometimes it happens that I open a file and make some modifications as my own user, without noticing or "forgetting" to noticing the [read-only] warning in the status line (ie. some random /etc config ...
4
votes
1answer
344 views

Making a box in vim via python

I am attempting to learn more about scripting vim and writing plugins with python, but I'm having trouble getting started. Although I've read :h python (first step, read the manual), I had trouble ...
38
votes
1answer
18k views

Why do I need both a vimrc and a gvimrc?

There seems to be two ways to store preferences specific to gvim: Keep an .vimrc file for vim and a .gvimrc file for gvim specific additions. Keep all settings in .vimrc and wrap gvim specific ...
5
votes
1answer
76 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
3k 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 ...
27
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
98 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 ...
115
votes
7answers
37k 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 ...
139
votes
5answers
91k 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 ...
145
votes
5answers
73k 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
124 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 ...
72
votes
5answers
14k 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
109 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
113 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 ...
12
votes
2answers
4k 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 ...
119
votes
6answers
117k 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
326 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
5answers
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
502 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
688 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
886 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
800 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
897 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,...

15 30 50 per page