Tip 1582 Printable Monobook Previous Next
created February 16, 2008 · complexity basic · author Metacosm · version 7.0
The #vim community started this FAQ to help solve some common problems enountered by new users of Vim.
Using help
Search highlights
- :help 'hlsearch' – turn them on or off permanently
- :help :nohlsearch – turn them off until the next search
Backspace behavior – how to backspace over line-endings and more
Do something to all lines matching a pattern
Format options
End-of-line problems (extra ^Ms all over the place)
Indenting
- Category:Indenting
- :help 'expandtab'
- :help 'shiftwidth'
- :help 'tabstop'
- :help 'copyindent'
- :help 'preserveindent'
- :help sub-replace-special – for why \n doesn't do what you want in s///
Not indenting when pasting
Making invisible characters visible (tabs, newlines, trailing spaces,...)
Show matching braces
Answered questions
- Vim is confusing, where do I start? New to Vim, Tutorial, Vi-Improved.org Tutorial
- How do I record a macro? Macros
- How do I edit GPG encrypted files in Vim? Edit gpg encrypted files
- How do I reselect the visual range I just used? Visual selection
- How do I change the GUI Font (and make those changes stick)? Change font
- How do I make backspace work like in other editors? Backspace and delete problems
- How do I fix syntax highlighting problems? Fix syntax highlighting
- How do I paste in code without having all the indenting screwed up? Toggle auto-indenting for code paste
- How do I insert the current date/time into my file? Insert current date or time
- How do I make the options I set STAY set? Debug unexpected option settings
- How can you read/write system environment variables from within Vim? Environment variables
- How can I dump my file to html looking EXACTLY as it currently does (syntax highlighting at all)? Pasting code with syntax coloring in emails
- How to tell Vim to save as a new file when the file is hardlinked? Editing a hard link to a file
- How can I fix the line-endings in this file? File format
- How to exchange the current line with the line above/below? Swapping characters, words and lines
- How can Vim work with Visual Studio .Net? Integrate gvim with Visual Studio
- How can I get diff to work properly in the MS Windows port of Vim? Cannot create diffs under Windows
- How can I get Visual Studio like completion (i.e. Intellisense) in Vim? Omni completion
- How can I delete parens that surround text? See Surround at Best plugins
- Why do letters show up when I try to enter numbers from the keypad? Why doesn't the numpad work as expected? Why does the NumLock key bring up help.txt? PuTTY numeric keypad mappings
Unanswered questions
- How can I remap the escape key to toggle insert mode? By default, INSERT starts insert mode, and ESCAPE takes you back into normal mode. How can I map ESCAPE to do both, toggling insert mode? -- Anonymous 21:37, 6 August 2009 (UTC)
- How can I make keywords autocompletable when creating a new C source file?
- Make sure Vim knows it is a C file: e.g., open it with :e main.c, not just :enew. — Tonymec 16:17, 4 August 2009 (UTC)
- How can I redirect stderr output in Windows ? I have a problem setting 'makeprg' with a compiler whose error messages can't be caught with '>'.
- I believe this question is now obsolete. The default value of 'shellpipe' on Windows seems to be ">%s 2>&1" which will (with the "2>&1") redirect stderr output from :make. The help does not reflect this default value, however. It looks like the support was added back in 6.1.105 but never made it into :help 'shellpipe'. --Fritzophrenic 16:07, 23 March 2009 (UTC)
- :help 'shellpipe' talks of "Amiga and MS-Dos" OT1H, of *sh shells OTOH, but doesn't mention W32 (as distinct from MS-Dos). Maybe it should. — Tonymec 16:17, 4 August 2009 (UTC)
- For encrypted files, :help encryption states: "Text you copy or delete goes to the numbered registers. The registers can be saved in the .viminfo file, where they could be read. Change your 'viminfo' option to be safe." Wouldn't it be a lot better if Vim by default would not write all your sensitive information to the viminfo file?
- The registers are a useful place to keep permanent (or semi-volatile) information which will be saved in the viminfo file at closedown and restored at the next startup. I think the 'viminfo' default is sensible; it's only when editing encrypted files that registers can be viewed as containing "sensitive information". If all your files are encrypted (which I don't think should be the Vim default) you can change the 'viminfo' option in the vimrc. Or you can define a user-command, let's say :XX, which will both prompt the user for an encryption key and change the 'viminfo' option — maybe even set it to the empty string. — Tonymec 16:17, 4 August 2009 (UTC)