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

learn more… | top users | synonyms

5
votes
2answers
3k views

Change colors in console/virtual terminal

Is there a way to alter all the available colors in console / virtual terminal? By console, I mean what you get after pressing CTRL + ALT + F1 and not anything like xterm or urxvt. So, I guess that ...
5
votes
2answers
992 views

exact match in regrex when using vim, man, or less

when using vim, man, or less, I want to do some exact match in regrex for example, when using man, I want to check the argument '-c' if I use /'-c' the matching could be -cim ...
5
votes
2answers
1k views

vim custom pop up menu

How do I create a custom completion pop up menu. I would like to be able to begin typing a part of a string then press a custom key combination to bring up a pop up completion of just a certain group ...
5
votes
3answers
309 views

vim regex not need \ to escape

In Vim is there an option to write regexs in the same style as Awk for example/sp\{0,\}/ Would be /sp{0,}/
5
votes
2answers
2k views

Using vim to view the contents of a directory file

As I understand, in Linux directories are mostly normal files w/ some special handling (e.g. 'rm' a file is ok; 'rm' a dir will complain w/o -r). When I execute the following bash commands: mkdir ...
5
votes
2answers
6k views

“No protocol specified” when running vim with sudo

Recently I start to get "No protocol specified" when using sudo vim. It's just a warning I guess, because everything was working normally (I can open, edit and save files). The message doesn't appear ...
5
votes
1answer
1k views

vim auto indenting even after setting noai option

I am using vim 7.2 from putty terminal. Even if I run set noai it seems vim still trying to indent code. I am copying my code from Notepad++ to vim. following is from Notepad++ and following what I ...
5
votes
2answers
730 views

Does using ctrl+c instead of esc to exit insert mode break anything in vi?

When using vi, you can exit insert mode with Ctrl + C instead of the more traditional Esc. Are there any situations where it would be undesirable to use for former instead of the latter? Does it break ...
5
votes
1answer
2k views

Why is vim creating files with DOS line endings?

I have set fileformat=unix in my .vimrc, and yet if I create a file in vim (running in Cygwin) it persists in creating DOS files, and I have to run the little cotton-pickers through dos2unix to ...
5
votes
2answers
1k views

Is it possible to create and use menus in (terminal-based) vim?

I'm setting up virtualized Linux boxes (as local development servers) for developers at a company that is primarily Windows-based, and some of developers make negative cracks about vim (among other ...
5
votes
2answers
331 views

Make vim / curl recognize https:// links

I recently noticed vim/vimdiff can open links (using curl, it seems), which is an awesome feature. I wanted to use it today, like this: vimdiff deps ...
5
votes
1answer
315 views

Why doesn't vim ask for password when reopenning an encrypted file?

If I run Vim and then open an encrypted file it asks for the encryption password. If I close the window where the file was opened (without closing vim) and then reopen the file, the password prompt is ...
5
votes
1answer
5k views

Vim 7.3 with Lua: How do I use it?

The latest Vim release is awesome! I compiled it with --enable-luainterp=yes and it does have the Lua feature: % gvim --version | egrep '\+lua' +linebreak +lispindent +listcmds +localmap +lua +menu ...
5
votes
2answers
685 views

Lowercase all but the first (Uppercase) letter from UPPERCASE in cyrillic

To make all letters a lower case except the first letter. The first letter would look like "Uppercase" after I changed (from UPPERCASE in cyrillic). The rest (not UPPERCASED) leave unchanged. I'm ...
5
votes
1answer
471 views

Conditional search and replace on a line in vim?

Let' say I want to comment and uncomment a line. I know I can :s!^!//! and then :s!^//!! Now what if I want this as an one-liner? Basically, if a line starts with // then remove it, else add ...
5
votes
2answers
49 views

How do I pick up a previous modification in VIM?

If I did several modifications to the original file, i.e. 1 delete a line 2 insert some text 3 delete another line 4 delete the text added in step 2 5 insert some other text 6 ... Now I want to ...
5
votes
1answer
293 views

How can I jump to files from vim opening them in a separate tab?

I have installed tags so I can jump to a function body in another file via CTRL + ] I know that I can do gf to jump to another file. I know that I can do CTRL-w s to split the vim window. What I don't ...
5
votes
3answers
1k views

E763 with vim and spell checker

I want to add germand spell checking to vim. So I set :set spl=de_de spell then there is a dialogue, where I can create a directory called .vim/spell. And then there is another question where I can ...
5
votes
2answers
633 views

viewing info documentation with vim

I'm trying to use the ManPageView addon to view info documentation within vim. Although I find ManPageView very useful for, well, viewing manpages, its info-reading functionality doesn't seem to work ...
5
votes
3answers
2k views

In vim, search backwards for matching braces/parens

As most of you probably know, you can use % to search forwards on the line to find the next paired brace/bracket/paren and move to its matched partner: |a|rray[index] = value; " |e| is the cursor; ...
5
votes
2answers
44 views

Color coding html color sequeces in vim

It it possible to setup syntax highlighting in vim so that a html color sequence is colored in that color, e.g. #FF0000 would show up as red. I'd also be ok with it underlining the text that color ...
5
votes
2answers
770 views

Carriage return vs newline in vim

In vim, when I opened a file, I wanted to add two empty lines at the end of each current line. I used the following switch: %s/$/\n\n/ Apparently, this does not work, but what does work is: ...
5
votes
2answers
189 views

How to consistently start Vim's command line to make a mapping work in any mode?

I try to normalize access to Vim's command line mode from any other mode in order to simplify my actual mappings. For example to make the <f6> key work from anywhere I define the following ...
5
votes
1answer
665 views

Trying to get vimpager (to replace less) working with nerdTREE

I'm trying to get switch over to vim as my primary editor and I've installed the nerdTree plugin, but now when I try and use vimpager to replace less I get Error detected while processing VimEnter ...
5
votes
1answer
76 views

Copy/paste across vim without X

In vim, "+p pastes from the system clipboard. However, when working remotely over SSH on a non-GUI box, this is not available. Is it possible to implement copy/paste in this environment? Merely ...
5
votes
2answers
137 views

Make vimdiff display different lines as different lines (not partially different)

vimdiff has an annoying habit of displaying two almost-completely-different lines as the same partially-different line just because they share a character in common at the beginning or end. For ...
5
votes
2answers
886 views

How can I disable terminal resizing

Vim scripts sometimes resize the whole shell (in my case the Taglist plugin). I don't want this behavior, which is possible with the shell command resize, too. Is there a way to suppress the whole ...
5
votes
1answer
123 views

Vim syntax highlight certain lines

I have php files well any file type in general that I would like vim to highlight here docs sections using a different syntax highlighting. <?php echo <<<HTMLDOC <h1> I am ...
5
votes
3answers
463 views

Search and replace next n words in vi [duplicate]

Possible Duplicate: Vim :s replace first N < g occurrences on a line In vi, how do I search and replace a word's first n occurrences with a word, say "hello", and the next m occurrences ...
4
votes
3answers
3k views

vi/vim, how can I write out a number of lines to a new file

I have a bunch of lines that I want to write out to a different file. How can I do that?
4
votes
3answers
403 views

Switching among cli and vim and other files workflow

I saw some kind of workflow in vim: Vim had a file open. Then some combination of keys made vim disappear and the user was in the command line working in cli mode, then opened another file and then ...
4
votes
4answers
2k views

less command and syntax highlighting

I need to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages. How do I apply syntax highlighting colors according to vim colors for less ...
4
votes
3answers
329 views

Any way to provide a separate vimrc file just for 1 session

I would like to know, if there is a way in vim/vi to provide a different vimrc file. I am looking at managing 2 different vimrc files. For the contents I checkout/checkin in version control I want to ...
4
votes
2answers
418 views

Sudoedit Vim force write (update) without quit

I'm doing some scripting with Vim and I've just started using sudoedit. Problem is, when I :w it writes to the temp file, so any testing of the script can't happen unless I quit the editor. How can ...
4
votes
2answers
4k views

How can I set “vi” as my default editor in UNIX?

I believe I can do something like export EDITOR=vi, but I'm not sure what exactly to enter, and where. How can I set "vi" as my default editor?
4
votes
3answers
162 views

What's the syntax for selecting a range of lines in Vim?

What's the syntax for selecting a range of lines? I want to run a command over lines 1405 until 1700. And one from 1405 until the end of file, without wanting to look up that number. Update: Is it ...
4
votes
3answers
1k views

What does [converted] mean at the bottom of vim?

I have a log file, and when I open it via vim, it looks not readable, and it has [converted] at the bottom. What does [converted] mean? Is there a way to fix the format issue so that it is human ...
4
votes
3answers
817 views

`grep -l .. | xargs vim` generates a warning, why?

If I run a command like grep -rl test . | xargs vim I get a warning "Vim: Warning: Input is not from a terminal." But I am still able to edit the files. Why the warning?
4
votes
4answers
15k views

“Swap file xxx already exists” when editing apache configuration file in vim?

Using vim I keep getting a message saying "Swap file xxx already exists" when I'm editing an apache config. However, I don't see it in the working directory on in tmp. How do I delete this?
4
votes
4answers
2k views

vim search numbers containing specific number of digits

I need to find specific length numbers in a big document. I tried to use regex for this. For example, If I need to search for numbers with exactly 2 digits, I use /d/d (i.e. /d twice followed by a ...
4
votes
1answer
179 views

Different vim colorscheme depending on mode

I'm often doing the same mistake in vim: I forget whether I'm in insert or command mode, then I type in, I get random commands or I modify/delete code, and I have to undo. I do this mistake really ...
4
votes
1answer
230 views

How to store Vim tabstop settings in the file?

I need different tab widths for different files when using Vim. Is there a way to store this information in the file, and let Vim apply the setting automatically?
4
votes
2answers
109 views

How can I use caps lock to change language in VIM

Can I use capslock for changing languages in VIM instead of Ctrl + 6 in case of "keymap=russian-jcukenwin"? How can I do it? Maybe something like mapping it in the $VIMRC file? How can I map ...
4
votes
2answers
310 views

echo a customized message with VIM editor

How can I deltect if there is a file modification in VIM upon exiting (:q)? If there is a file modification Vim echos E37: No write since last change (add ! to override) I want to override this ...
4
votes
1answer
232 views

Idle terminal safe character

I'm using iTerm2 on a Mac to do Linux work. In order to avoid losing terminal connections, I turned on "When idle, sent Ascii code". The default is 0. This works like a charm to keep connections ...
4
votes
2answers
315 views

VIM substitute occurrences of pattern after a particular word in a line

I have such lines in my text. text before pattern = garbage** text after pattern is pattern If in VIM I do %s/pattern/saturn/ it replaces all occurrences of pattern. But I only want to replace ...
4
votes
3answers
1k views

Running external commands in vim

It seems that if I run the following inside the vim: :w !wc -w I get the word count of the file. But I don't understand the syntax. How does this work and how would I specify that I want the ...
4
votes
3answers
1k views

Can't open syntax.vim error when using vimrc

When I try to open my .bashrc file. then it shows these lines: Errordetected while processing /etc/vimrc: line 45: E848: Can't open file /usr/share/vim/vim70/syntax/syntax.vim Press ENTER or type ...
4
votes
1answer
876 views

How to automatically refresh Vim on buffer/window focus?

I often use Control+L to redraw the screen in Vim. In particular, when I come out of sleep or change monitor configurations I often find that Vim needs to be redrawn. I thought it might be simpler to ...
4
votes
1answer
264 views

Switching between split buffers in vim

recently starting trying to use VIM as my full-time text editor since I spent a lot of time SSH'ed anyways. Recently installed NERDTree so I can quickly swap between files in a project. Easy question ...