vim

How do I insert a linebreak where the cursor is without entering into insert mode in Vim?

Is possible to insert a linebreak where the cursor is in Vim without entering into insert mode? Here's an example ([x] means cursor is on x): if (some_condition) {[ ]return; } Occasionally, I might want to enter some more code. So I'd press 'i' to get into insert mode, press enter to insert the linebreak and then delete the extra spac...

vim -- How to read range of lines from a file into current buffer

Hi I want to read line n1->n2 from file foo.c into current buffer. I tried :147,227r /path/to/foo/foo.c But I get "E16: Invalid range", though I am certain that foo.c contains more than 1000 lines. Thanks Aman Jain ...

What's the best thing you've done with vim that helped your programming?

Hi While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!! Can you people share what all cool things you have been doing in vim. Thanks Aman Jain Edit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-opened to allow people to comment on ...

use vimdiff with a diff file

How can I use vimdiff to view the differences described in a diff file? ...

Is there any command to toggle enable auto text wrapping?

By default, I think my vimrc setttings enable the auto-wrapping. However, sometimes, I would like to see text lines are not wrapped. Is there any command I toggle the text line wrapping enabled and disabled? This would avoid me to exit and to change settings. ...

VIM initial settings: change backgound color for line number on the left side?

I use _vimrc to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting). I would like the background color for line numbers to be Grey or dimmed color. ...

VIM visual mode: highlight last 2 chars in each line?

I like vim's visual mode. v for highlight/select chars or lines, Ctrl-v for rectangle highlighting, as far as I know (I am a beginner). Is there any way to use visual mode to highlight last two chars, for exmaple, on each line for some selected lines? The selected lines are in different length. Basically, I would like to find a quick way...

Add line numbers in vim

How can I add line numbers to a range of rows in vim? Not as in ":set nu" - this just displays numbers, but doesn't add them to the file. ...

Tips for using vim as a Java IDE?

I'm addicted to vim, it's now my de facto way of editing text files. Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing java apps. Some questions I have: How do I invoke a maven task without leaving vi Can I get code completion? How's the syntax highlighting? Anythi...

How do I insert text at beginning of a multi-line selection in VI/VIM?

In vim, how would I go about inserting characters at the beginning of each line in a selection? For instance, let's say I want to comment out a block of code by prepending '//' at the beginning of each line (assuming my language's comment system doesn't allow block commenting like /* */). How would I do this? ...

Why vim doesn't work correctly into a telnet session ?

Hello, I use vim (7.1) on OpenVMS V7.3-2. I connect to VMS trough a telnet session with SmartTerm, a terminal emulator. It works fine. But when I start a telnet session from a VMS session (connected via SmartTerm) to another VMS session, some keys doesn't work properly. |--------------| telnet |-------------| telnet |-----------...

Scripting common tasks in Vim

While using Vim (at home and at work), I often find myself doing similar things repeatedly. For example, I may turn a bunch of CSV text into a series of SQL inserts. I've been using Vim for years, but only recently have I tried to seriously think about how I could improve my productivity while using it. My question is.. Is there a good ...

What feature is missing or hidden in Vim?

I thought I'd have a try at using Win32 GVim, and I'm finding that it's much more versatile than I realised. At this point I'm finding that for myself a lot of its features are still hidden. As an example I'm used to having a button on the toolbar to run external commands and capturing the output but I found in Vim it's :%!<command> to g...

VIM: Close file without quiting VIM application?

I am new to VIM. I use e and w commands to edit and to write a file. It is very convenient. I am not sure if there is "close" command to close the current file without leaving VIM? I know that q command can be used to close a file. But if it is the last file, the VIM is closed as well(actually on Mac the MacVIM does quit. Only the VIM w...

% VIM Key Command

Is there a way to have % in vim find the next ([{ or whatever, even if it is not on the same line? Example: int main(int argc, char ** argv) { #Your cursor is somewhere in this comment, I want #it to get to the ( after printf printf("Hello there.\n"); } ...

Color margins in VIM

Does anybody know how I can get diff's color margins in VIM (if it is possible)? I mean something like this: (e.g., in NetBeans: Netbeans color margins). It was very useful when I was working with NetBeans, maybe somebody wrote such useful plugin for VIM? Thanks! ...

In VIM command line mode what is the special character/symbol for current line?

In VIM in command line mode a "%" denotes the current file, "cword" denotes the current word under the cursor. I want to create a shortcut where I need the current line number. What is the symbol which denotes this? ...

Vim File Explorer Configuration

I'm setting the below variables in my vimrc to control how windows get split when I bring up the file explorer plugin for vim. But it appears these variables are not being read because they have no effect on how the file explorer window is displayed. I'm new to vim. I know the vimrc file is being read because I can make other setting cha...

Vim - how to start inserting at the end of the file in one step

Is there a single shortcut to start inserting in the new line at end of the file? I'm aware of G + o combo. ...

How do I force keywords to automatically capitalize in the VIM editor?

Does anybody know how to edit a syntax file for VIM so that keywords are capitalized automatically? I need to do this to keep my coding style consistent with the rest of the developers in my team. I'm using VIm version 7.2 (actually gVIM) and the syntax file I'm using is the Progress.vim file (installed automatically with VIM under the ...