vim

Automatically go to next line in vim

Hi. One frustrating behavior in vim is that when i move my cursor right or left (respectively "l" or "h)" and i am at the end or the beginning of the line, my cursor doesn't move to first column of next line or last column of previous line. Is there a way to change this behavior ? ...

ctags doesn't work when class is defined like "class Gem::SystemExitException"

You can define a class in a namespace like this class Gem class SystemExitException end end or class Gem::SystemExitException end When code uses first method of class definition, ctags indexes the class definition like this: SystemExitException test_class.rb /^ class SystemExitException$/;" c class:Gem Wit...

Vim: Pipe selected text to shell cmd and receive output on vim info/command line

I want to pipe the selected text to a shell command and receive the one-line output from this shell command on the vim info/command line? What I'm really trying to do: Pipe the selected text to a pastebin-type shell command and I want to receive the output of the shell cmd (which is the http link to the pastebin). Is this possible? ...

vim filters and stdout/stderr

When I use :%! to run the contents of a file through a filter and the filter fails (it returns another code than 0) and prints an error message to stderr I get my file replaced with this error message. Is there a way to tell vim to skip the filtering if the filter returns an status code that indicates an error and/or ignore output the fi...

vim: highlight bash scripts?

my vim editor auto highlights php files (vim file.php), html files (vim file.html) and so on. but when i type: "vim file" and inside it write a bash script, it doesnt highlight it. how can i tell vim to highlight it as a bash script? i start typing #!/bin/bash at the top of the file but it doesnt make it work. ...

How to distinguish between <expr> and non-<expr> mappings?

I want to add a possibility of restoring mappings overwritten by my plugin. But the problem is that I cannot distinguish between the following mappings: inoremap <expr> @ test and inoremap @ test First mapping inserts the contents of the variable test, while second inserts text «test». Both mappings give maparg("@", 'i')=="test" an...

How can I swap positions of two open files (in splits) in vim?

Assume I've got some arbitrary layout of splits in vim. ____________________ | one | two | | | | | |______| | | three| | | | |___________|______| Is there a way to swap one and two and maintain the same layout? It's simple in this example, but I'm looking for a solution that ...

Are there any kata for practice VIM?

I've used VIM for many years as my primary text editor. And I am still learning how to use VIM for various editing tasks. The problem is that even if I learn something and use it once a week I forgot soon how I did it -- classic case is search and replace in many buffers using bufdo :(. I was wondering if there is any kata to daily VIM...

Vim configuration, setting up autocomplete, and columns

How do I set up auto-completion for C? I've heard it's language agnostic. How does this work? Where can I find a list of settings available for vim? I often find that code is usually occupying the left side of my screen when editing. How can I have the next "page" or so of code displayed on the right side, treating the column on the rig...

What do these signs mean in Vim?

I've a hard time understanding signs I see in my text editor Vim. I see signs like ^@ and ^A and ^M and ^F. What does this mean? Is there any structured list of these signs and their meaning? Trying to google it is a dead end since Google will not search for "^@". ...

Calling omnicompletion for every keypress in vim

I have a vim script that uses a one line window to get a filename pattern from the user. This pattern can be completed to a full filename from a database if you press CTRL-X CTRL-O. Now the only problem is that you have to press the auto completion shortcut by yourself. But I want the auto completion to work incrementally so that for eve...

What's the most efficient way to repeatedly remove leading text using Vim?

What's the most efficient way to remove the text 2010-04-07 14:25:50,773 DEBUG This is a debug log statement - from a log file like the extract below using Vim? 2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 9,8 2010-04-07 14:25:50,772 DEBUG This is a debug log statement - 1,11 2010-04-07 14:25:50,772 DEBUG This is a deb...

How do you edit tab labels per tab in GVim?

How do you edit a tab label, per tab, in GVim? You can do this: set guitablabel=foo But that will set every tab's label to "foo". The documentation seems to suggest using a t:var, like this: let t:guitablabel="foo" But it doesn't do anything. Is there any way to give each different tab a different name? ...

Print problems in GVIM

I have set linebreak and wrap. The document looks great on my screen but when I print it the words are broken p.e. this is the text of my printed docume nt How can I resolve this problem? ps: I don't want to reformat the text, I would like to keep the text as it is on the screen. I would like to have also a bit more right margin spa...

vim, any way to copy'n paste, using the mouse, without using shift

I'm used to most X11 apps that copy'n paste with a simple middle mouse key. In vim I must remember to hold the shift key. Is there any way in vim to copy'n paste using the mouse without the shift key? ...

How do I get the length of a regex match in vim?

If I want to get the length of each match within the parentheses in the following regex, how do I do it?: ^\(\-\+\s\)\+ I'm trying to modify the width of columns in a buffer with data that is laid out as a table. Since the first two rows of the table will look like this DESIGN_ID DESIGN_YEAR SOURCE_REFERENCE ---------- ----------- ...

Splits and windows in vim/emacs/etc.: can we have buffer-specific splits?

I'm using Charles Campbell's MPage[0] plugin to get multiple pages open, so I have vertical splits open for one buffer. My question is: can I have another display without splits open for another buffer, and switch back to the display with splits, without opening another instance of vim? It's easy to do so using tmux or the like, bu...

How do I make git use the editor of my choice for commits?

For example, I would prefer to write my commit messages in vim, but it is opening emacs. How do I configure git to always use vim instead? Note that I want to do this globally, not just for a single project. ...

How does the vim "write with sudo" trick work?

Many of you have probably seen the command that allows you to write on a file that needs root permission, even when you forgot to open vim with sudo: :w !sudo tee % The thing is that I don't get what is exactly happening here. I have already figured this: w is for this *:w_c* *...

Multiple file types in vim

When I am working on a PHP file for example the default filetype is php. This makes sense, however when that PHP file has HTML as well the filetype is still only php. For some plugins that means that I get the PHP functionality for that plugin, but miss out on the HTML functionality. A more specific situation where this happens is with m...