Questions tagged [vim]

vim (Vi IMproved) is a text editor supporting different editing modes.

vim (Vi IMproved) is a modular text editor that is upwards compatible to vi.

The speciality lies within the editing modes which provide different tasks. Each mode can be reached by one or more specified keys.

  • Normal (ESC): copy, (re)move, replace words and lines, text formatting
  • Insert (i,a,o): insert or remove text
  • Visual (v): visually highlight a text area
  • Select (gh): modify selected text area
  • Command-line (:): complex commands, search(-replace), filter, (un)set options
  • Ex (Q): like command-line mode but stays in Ex mode after entering a command

Further, vim provides the following features:

  • Syntax highlighting
  • Autocorrection
  • Tabs and Splitscreens
  • undo/redo operations
  • Plugin support over own scripts
  • Archive editing (tar, gz, zip)
  • History
  • Wrapping
  • Macros
  • and more...

On modern Linux systems, vi is generally linked to vim.

vimtutor gets you started with vim in a short time.
vim also provides a great help section, start the editor and type :help.

More ressources:

  • vim.org
  • man vim
  • /usr/share/vim/current/doc

Further reading

Useful Links

1850 questions
435
votes
4 answers

refresh changed content of file opened in vi(m)

I have a config-file that I keep open in vim, but that sometimes gets changed on disk, without these changes being reflected on the terminal. Can I refresh the content on the screen without closing and re-opening the file? If so, how?
twan163
  • 5,690
98
votes
9 answers

How to insert the result of a command into the text in vim?

For instance, :echo strftime(%c) will show the current time on the bottom, but how to insert this time string into the text (right after the cursor)?
xzhu
  • 1,362
97
votes
6 answers

How to enable and use code folding in Vim?

How can I enable and do code folding in Vim? Do I have to change anything in ~/.vimrc? I type z+a and z+c and z+o and nothing happens. Here is an article about folding: Code folding in Vim.
Mohammad Reza Rezwani
  • 1,235
  • 2
  • 10
  • 9
79
votes
9 answers

How to find out which file is currently opened in vim?

This may sound trivial but, on more than one occasion, I have found myself having forgotten which file in vim I have open (e.g. when I am looking through different log files and such) and the only way I knew how to find out was to close the file and…
amphibient
  • 12,472
  • 18
  • 64
  • 88
75
votes
9 answers

Auto indent / format code for Vim?

I'm trying to use Vim more and more when I can. One of my biggest grip between Vim and an IDE like Aptana is the ability to auto indent. Is there a means of auto formatting code (HTML, CSS, PHP) so it is properly indented? If so how do you install…
chrisjlee
  • 8,523
68
votes
6 answers

How to select/delete until end of file in vim/gvim?

Accidentally I managed to copy-paste a paragraph in vim a zillion times. How do I select and then delete the text from my current position to the end of file? In Windows, this would be Ctrl-Shift-End, followed by Delete.
ripper234
  • 31,763
59
votes
6 answers

How do I insert the current filename into the contents in Vim?

After some searching, I got to know :echo @% displays the current filename in the bottom line of vim-screen. I would like to dump the filename (with and without full path) into the contents of the file without leaving vim. Is there any way to do…
mtk
  • 27,530
  • 35
  • 94
  • 130
57
votes
3 answers

Why is vim frozen?

I have two different machines (home and work) running Ubuntu 18.04. Last night vim froze at home. I was in insert mode and typing and went to save (esc :w) and nothing happened. The status bar still reads -- INSERT --, the cursor is still blinking…
Amanda
  • 1,759
  • 2
  • 14
  • 26
55
votes
5 answers

How can I constantly see the current filename in vim?

I am using vim and I need a way to always be able to see the file that I am working on without having to do ^G. I see the file name when I start vim but when I start to work and use various functions it gets lost. Also I have seen other people have…
Jim
  • 10,120
52
votes
7 answers

How to send the ESC signal to vim when my esc key doesn't work?

I'm having a problem with the Esc key when I want to return to the interactive mode from the insert mode. Is there exist another key used to release the insert mode.
50
votes
9 answers

How to yank a particular line without moving the cursor in vim?

For example How can I yank and paste Line 4 only to Line 12 without having to move the cursor to Line 4?
Lazer
  • 35,307
49
votes
4 answers

What does the noeol indicator at the bottom of a vim edit session mean?

I opened a file using vim on Ubuntu, and the following is displayed at the bottom of the screen: "file.py" [noeol] 553L, 16620C What does noeol indicate?
Bon Ami
  • 893
47
votes
1 answer

Can't exit Vim with :!q

I have made wrong changes in a text, and now I want to leave Vim without saving. I know I have to type :!q while in normal mode, but when I do this, it says: [No write since last change] /bin/bash: q: command not found shell returned 127 Press…
Rodrigo
  • 1,832
44
votes
2 answers

Is there a way to place a comment in a file which vim will process in order to set filetype?

For example, if I want to have a file with the name gitconfig (no leading .) be recognised by vim as being of filetype=gitconfig, is there a means of indicating this in a comment or something similar within the file itself? Note, I want this to work…
42
votes
7 answers

vim: replace all character till end of line

Maybe I am being daft but can you replace all the characters from where the cursor is to the end of line by one command? Then use . to do the same replace on the next line and so on.
1
2 3
24 25