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

learn more… | top users | synonyms

2
votes
2answers
227 views

What does :p[rint] do in vim?

The help text is a little vague as to what this command achieves. Print [range] lines (default current line). Note: If you are looking for a way to print your ...
7
votes
2answers
2k views

Make sed ask for confirmation before each replacement?

Is there a way to make sed ask me for confirmation before each replace? Something similar to 'c' when using replace inside vim. Does sed do this at all?
2
votes
1answer
114 views

Getting vim to be silent when using -s {scriptin}

The vim man page describes -s {scriptin} option which allows for automation of file edits. This works fine, but I'd like for vim not to grab the console in this case (and flash the file with edits), ...
6
votes
4answers
8k views

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 ...
9
votes
1answer
3k views

Setting vim filetype with modeline not working as expected

As per the accepted answer to this question, I'm attempting to use modelines in vim to force filetype detection in some files. For example, at the top of a file named gitconfig (note there is no ...
6
votes
2answers
2k views

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 ...
0
votes
1answer
66 views

vim always shows help/documentation

Whenever I run vim, it randomly shows the help/documentation at a non particular time. How do I disable that. It's irritating.
4
votes
1answer
233 views

How can I make VIM a full fledged IDE [closed]

How could I make VIM a full fledged IDE by using different supported plugins for YUI, JQuery and git integration etc.
5
votes
1answer
764 views

Type from right to left

Is there a command to make Vim type from right to left? If not us any one aware of this plugin?
1
vote
1answer
407 views

How to set keycodes manually in vim?

Sometimes when I fire up vim, my Insert key doesn't work (need to use i) and my arrows don't work (they give me letters instead). I'm guessing this has to do with my keys not being mapped correctly. ...
2
votes
1answer
474 views

vim script: how to change “put =” to an append?

I'm trying to hack the c-vim plugin because I don't like the way it inserts comments. I want this: /* comment */ but it gives me this: /* comment */ I'm sure it has its reasons, but I don't ...
2
votes
1answer
129 views

Vim Highlight only the characters, which produce comments

I am trying to achieve the following. If I have a file, e.g. a tex document and I want to have the following with commenting characters (% symbols) highlighted: % Some text and end of the ...
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 ...
2
votes
1answer
169 views

Why does Vim have different cursor positions for different modes?

Why does vim have different cursor positions for the different modes? First, in insert mode, the cursor is between characters (like every other editor), second, in command mode, the cursor is under a ...
3
votes
1answer
2k views

vim is too slow when saving files

I run vi under Linux CentOS 5.3. Each time I exit from a file, I have to wait several seconds before vi saves the file. The same thing happens with vim. I ran this command: strace -odetails -ff -f ...
10
votes
2answers
2k views

Select code block in vim

Given a code like this: 588 while ($linecounter > 0) { 589 $token = " "; 590 while ($token != PHP_EOL) { 591 if (fseek($handle, $pos, SEEK_END) == ...
5
votes
2answers
248 views

Problem : how can I copy/paste this in vim?

I'm working with the vim editor and I found y,yw respectively to copy a line and a word but how can I do the following task in vim? www.pack.google.com From this line how can I copy and paste ...
4
votes
1answer
171 views

Rewrite a Vim function to a one-line map

This works: nmap <silent> <S-t> :call InventTab()<CR> function InventTab() set expandtab! if &expandtab retab echo 'spaces' else retab! ...
5
votes
1answer
326 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 ...
3
votes
2answers
166 views

The right way to wrap block of lines in custom text in vim

I would like to be able to select several lines using vim when editing an HTML file, then enter some hotkey and get these lines wrapped in a django comment block. For example, I have: one line ...
1
vote
1answer
573 views

How to change vim auto-indent behavior?

By default vim aligns lines inside LI tags on the same position as the position of LI tag, but I want the contents of LI to have deeper indentation. Current behaviour: <LI> first line second ...
2
votes
2answers
132 views

Vim markers and macros

Is there a way to make a macro operate up to a marker? I know if I do 5@a my macro will operate on 5 lines. Example: set marker with `mc` record a macro with `qa` ... now what? Obviously 'c@a just ...
3
votes
3answers
494 views

Open another file with split windows, and switch between them

If I open vim with: $ vim -o a.ext b.ext I get a window that looks like this +----------------------+ | a | | | | a.ext ---------------+ | b ...
7
votes
5answers
2k views

Indent several lines with VIM?

For eample, I'm editing this code: <html> <body> <script> var a = 10; a += 100; </script> </body> </html> now I need to indent the script line: ...
8
votes
1answer
181 views

making vim fold also hide newline after function

How can one make vim's fold function - when using foldmethod=syntax - also hide one newline after each function, if-else and struct (using Go).
9
votes
2answers
345 views

Vim, context-sensitive comment/uncomment behavior

I edit a lot of PHP code with Vim, and I've run into a snag with some macros in my .vimrc. I currently use these two macros to comment/uncomment in C-style "c-style (//) comment (press the [.] key) ...
2
votes
4answers
1k views

Turn NumLock on on startup?

I usually edit in Vim,and when pressing +, I'd rather move my hand to the right part of the keyboard where + resides rather than doing shift + =. But when NumLock is not on, in Vim it just opens a ...
7
votes
2answers
343 views

How do I get just the user-manual for Vim

To get the vim user-manual I am doing vi test and then, once the file is opened, I do :help user-manual This opens up a split window, which makes reading manual inconvenient to read. How do I ...
2
votes
1answer
440 views

Fall-back for $VIM is invalid

I am working directly on a dev server and want to build my own vim, for my purposes, not for all system users. The build scenario is: hg clone https://vim.googlecode.com/hg/ vim cd vim/src ...
1
vote
3answers
310 views

vim/emacs plugin to view recursive grep search search results?

Suppose I have a file formatted like this: file1:123 file2:4444 some/other/file:2233 This represents the search results from a grep (i.e. file:line-number). I'd like to have a vim plugin which ...
2
votes
2answers
901 views

ZSH tab completion: only complete files and not binaries

Is it possible to make a custom zsh completion file,so when hitting tab for filenames it avoids completing the binaries? For example,I have 2 files , myprogram.c and myprogram,the binary,is it ...
6
votes
5answers
3k views

vim editing/switching between multiple files efficiently in large directory structures

I am by no means a vim power user, I am just beginning to grasp the advanced motions and commands with vim. But there's one drawback that I can't seem to get around. I grew up with graphical ...
4
votes
2answers
5k views

How to map ALT key in .vimrc?

In order to be able add blank lines without going into insertion mode, I'm trying to map ALT-o and ALT-O to o<ESC> and o<ESC> I've tried the following in my .vimrc map <M-o> ...
7
votes
5answers
6k views

vi command for adding blank line?

In vi, I can use o or O to add a blank line and go into insertion mode. But what if I want to stay in command mode, is there a command for this? In googling, I'm seeing suggestions to add stuff to my ...
9
votes
4answers
2k views

Why would vim return non-zero exit code if I exit immediately after opening?

I'm running into a bit of a strange problem w/ vim on Snow Leopard: I get a non-zero exit code from simply running vim and then quitting. $ vim # exit immediately using :q $ echo $? 1 However, if I ...
4
votes
2answers
507 views

Vim keybinding to delete up to (but not including) the next period

I've noticed a common idiom in my editing is a desire to delete everything up to, but not including, the next period. After a bit of researching online, I found the following command will work (I ...
4
votes
1answer
659 views

Quit VIM is slow, usually 2 seconds, it shows

On quit, vim shows that: ".netrwhist" [Not edited] --No lines in buffer-- This process usually takes 2s. How to turn this thing off? --- Update --- I noticed that netrw is installed as ...
1
vote
1answer
615 views

Documentation for vifm?

vifm looks like a good file manager, but it lacks documentation. Is there a manual or tips on how to use it? I'm looking for information on copying/moving a dir, creating a new empty file, editing a ...
12
votes
4answers
455 views

Is there a vim shortcut for <name of current file>?

In vim, if I'm working on a Python script, I will commonly type: :! python this_script.py to execute the script. Is there a shortcut for the name of the current file? If not, can I easily make one? ...
4
votes
2answers
235 views

Vim - buffer names in the cmd line area

When I edit files with vim there is always this in the cmd line area,under the status line,all buffers' names(image : ) Is there any way I can remove it?
1
vote
3answers
2k views

Is it possible to execute a VIM script in a non-interactive mode?

The Gnats bug tracker has a command (edit-pr) that opens a ticket in $EDITOR. My $EDITOR is VIM, and when this command opens the ticket in $EDITOR, I'd like to automatically perform some scripted ...
4
votes
2answers
247 views

Indenting multiple files

I want to indent multiple files which are poorly indented and indent them properly as would vim do when I type gg=G. Is there someway to enter the = command or its alias in the command mode? i.e ...
12
votes
4answers
13k views

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 ...
3
votes
3answers
2k views

How to copy from one vim instance to another using registers

How can I select the + register? I have problems following the instructions below to copy/paste text from vim to another vim: In the vim, highlight, select + register, and yank (save) to it: Shift-v ...
2
votes
1answer
114 views

Script for opening corresponding pdfs for bibtex keys in Vim

Context I currently write research articles in LaTeX using Vim. I have bibtex keys in my articles like \cite{smith2000sometopic} and I have corresponding pdf versions of most articles in a subfolder ...
6
votes
1answer
161 views

Sending commands to dbx from Vim

Using this information, I've been able to debug code using dbx and display the code from within Vim. What would be really cool is if I could send commands (step, next, print, stop in ... etc) to dbx ...
1
vote
2answers
136 views

How to display the server time inside Vim

I want to know how to display the server time inside the Vim editor, if possible.
8
votes
2answers
763 views

vim spell checker?

Is there a way to spell check a file using vim?
12
votes
4answers
2k views

Replacing Multiple blank lines with a single blank line in vim / sed

Question more or less says it all. I'm aware that /^$/d will remove all blank lines, but I can't see how to say 'replace two or more blank lines with a single blank line' Any ideas?
32
votes
8answers
25k views

How to copy text from vim to an external program?

I'm trying to copy-paste some text from vim. I'm doing v to enter visual mode, then y once I selected my block. It appears to copy the text into vim's clipboard, because p will paste it. But in ...