Questions tagged [vim]

Vim is a free and open-source modal text editor available for most major platforms. It allows high efficiency in many text editing tasks but has a steep learning curve. To learn the basics, run ":help vimtutor". For non-programming questions please use https://vi.stackexchange.com/ instead.

Vim is a free and open source text editor with a steep learning curve that leads to high efficiency in many tasks related to text editing. If you wish to start with Vim, run :help vimtutor in Vim or run the vimtutor command in shell, which will teach you basic commands.

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems and is available on a large number of other systems including Win32, MS-DOS, OS X, AMIGA, OS/2, Cygwin and many more. Vim is written by Bram Moolenaar.

Vim is often called a "programmer's editor," and is so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.

Before you ask

  • If your question is not about programming, consider posting Vim related questions at the dedicated Vim Stack Exchange site.
  • Vim has an extensive help system that will often address your questions. Type :help <subject> within Vim to search for help on a particular subject; for instance: :help search. The help documentation is also available online.
  • Search Stack Overflow for similar or duplicate questions.

Free Vim books

Vim books

Documentation

Tutorial

See also

License/charityware

Vim is Charityware. You can use and copy it as much as you like, but you are encouraged to make a donation for needy children in Uganda. Please see |kcc| below or visit the ICCF web site, available at these URLs:

Related tags

27998 questions
26
votes
1 answer

Mixing two syntax highlighting scripts

I write blog posts with Jekyll, and for that I end up using three different languages in the same file: YAML at the start for post metadata, Markdown in the body, and C++ in code snippets. I tried to setup a script so that I can have vim highlight…
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
26
votes
11 answers

How to yank an entire block in Vim?

Is it possible to yank an entire block of Python code in Vim? Be it a def, for, if, etc. block...
john2x
  • 22,546
  • 16
  • 57
  • 95
26
votes
3 answers

Why vundle requires filetype off

On vundle's homepage, it documented that it requires filetype to be off in .vimrc: filetype off " required! set rtp+=~/.vim/bundle/vundle/ call vundle#rc() I don't understand why. Since I am encountering problems with editing…
Wayne Ye
  • 2,464
  • 3
  • 25
  • 29
26
votes
1 answer

Run vim without loading .vimrc but loading plugins

I'm running gvim -u NONE to open gvim without using .vimrc, but in the same time I would like to be able to call the commands from the plugins inside the plugin/ folder. I tried it running :filetype plugin on but it doesn't work.. Any idea how to do…
tirenweb
  • 30,963
  • 73
  • 183
  • 303
26
votes
4 answers

Vim CtrlP Plugin: Manually set root search directory?

I have read through the docs but cannot figure out if this is possible. I want to keep the default setting of g:ctrlp_working_path_mode = 2, but I want the ability to manually override that for all buffers in the current window if I want. …
Jonah
  • 15,806
  • 22
  • 87
  • 161
26
votes
2 answers

vim says "No mouse support", but only when I run git commit

I like using the mouse with vim, so I have mouse support enabled in my .vimrc. This works just fine most everywhere, but whenever I run git commit on a specific server (Appa), I get an error message: [tswett@appa git]$ git commit Error detected…
Tanner Swett
  • 3,241
  • 1
  • 26
  • 32
25
votes
5 answers

Vim scripting: Preserve cursor position and screen view in function call

I have some Vim functions that make changes to the document format. When I call this function, I currently use something like the following to save and restore my cursor position: func! Foo() :norm mz ... :norm `z endf This properly saves the…
JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169
25
votes
3 answers

Append or prepend selected text to a file in Vim

In Vim, is there a way to move the selected text into .bak, appending or prepending? If possible, the backup file should not be displayed. I envision the workflow to be: Select some text Type :sbak The selection is saved into…
greatghoul
  • 1,448
  • 1
  • 17
  • 19
25
votes
1 answer

How to enable horizontal scrollbar to pop when ‘nowrap’ is set in Vim?

Can someone help me to find a solution for the following inconvenience? I would like horizontal scrollbar to appear whenever I set the nowrap option, and vice versa when I set it back to wrap. Currently I use these settings individually to ease my…
James bond
  • 459
  • 1
  • 4
  • 13
25
votes
8 answers

vim compiles with wrong python version (and not working with needed version)

In brief: I have a problem with compiling vim with preferred python version. When I use --enable-pythoninterp it compiles with system OSX python version. When I use --enable-pythoninterp=dynamic I get an error in vim while trying :py import sys Here…
oluckyman
  • 3,566
  • 3
  • 28
  • 35
25
votes
2 answers

Leader mapping to toggle a vim setting

There are several Vim settings I love, but are too annoying to always enable. For example: set relativenumber - annoying when scrolling set list - distracting when you don't need it What is a concise leader mapping to toggle a generic Vim setting?
Natan Yellin
  • 6,063
  • 5
  • 38
  • 57
25
votes
4 answers

VIM, Run a command on multiple files

I have a bunch of sass files and my designer used the wrong syntax. I wanted :margin-top 1px but he did margin-top: 1px So I easily wrote a sub command: :rubydo sub! /([\w-]+):/,':\1' So that works and fixes all the colons and moves them in the…
Andrew WC Brown
  • 2,240
  • 5
  • 22
  • 24
25
votes
3 answers

Vim auto complete

So I know you can get Vim autocompletion with Ctrl-X, Ctrl-O but I'm wondering if you could rework it so it works with just pressing Tab (more like Textmate's snippets), or even just how I could remap it to something a bit shorter (even if I can't…
Jack Franklin
  • 3,765
  • 6
  • 26
  • 34
25
votes
5 answers

Compiling Java code in Vim more efficiently

I come from an Eclipse background, but I love Vim as a text editor. I'm currently experimenting with Vim as a Java IDE. Currently I do this to compile: ! javac MyClass.java followed by ! java -cp . MyClass If I have compile errors, I have to go…
Pieter
  • 31,619
  • 76
  • 167
  • 242
25
votes
5 answers

How can I achieve project specific indentation in vim?

I'm working on several projects, each of which uses different indentation style (for various filetypes). For example 1 tab per indentation level, 2 or 4 spaces etc. How can I automate switching between these different styles? I normaly prefer…
VoY
  • 5,479
  • 2
  • 37
  • 45