vim

Reordering methods using vim

I have 2 methods in a source file: def Foo puts "hello" puts "bar" end def Bar puts "hello" puts "bar" end I would like to swap the order of the methods, so Bar is first. Assuming the cursor is on the d in def Foo, the simple way is to: shift v -> jjjj -> d -> jjj -> p -> O -> esc But that feels a little long wind...

Making tabulation look different than just whitespace

How to make tabulation look different than whitespace in vim (highlighted for example). That would be useful for code in Python. ...

Regular expression in vim

How to replace the strings (4000 to 4200 ) to (5000 to 5200) in vim .. ...

Enabling filename completion in a new vim command

In vim, I want to create a new command that takes a file-name as its single argument. Is there a way to create such a command, so that the file-name-completion-magic (using tab) will work? ...

braces and operators coloring in vim for c++?

Hello. I want to customize a syntax coloring in vim for c++. But, unfortunately, i still can't find a correct name for braces (){}[] and operators +-/*% for c/c++/objc/objcpp. Any vim guru whi can suggest what name i must 'hi' in order to set color for items mentioned? ...

Can you force Vim to show a blank line at the end of a file?

When I open a text file in Notepad, it shows a blank line if there is a carriage return at the end of the last line containing text. However, in Vim it does not show this blank line. Another thing I've noticed is that the Vim editor adds a carriage return to the last line by default (even though it doesn't show it). I can tell, because i...

How do I make vim indent JavaScript in HTML?

Vim 7.0.237 is driving me nuts with indentexpr=HtmlIndentGet(v:lnum). When I edit JavaScript in a <script> tag indented to match the surrounding html and press enter, it moves the previous line to column 0. When I autoindent the whole file the script moves back to the right. Where is vim's non-annoying JavaScript-in-HTML/XHTML indent? ...

Smart Wrap in Vim

I have been wondering if Vim has the capability to smart wrap lines of code, so that it keeps the same indentation as the line that it is indenting. I have noticed it on some other text editor, such as e-text editor, and found that it helped me to comprehend what I'm looking at easier. For example rather than <p> <a href="http://ww...

Renaming the current file in Vim

How should I go about renaming my current file in vim. For example: I am editing person.html_erb_spec.rb I would like it renamed to person.haml_spec.rb I would like to continue editing person.haml_spec.rb How would I go about doing this, elegantly? ...

Would you recommend vim/emacs for beginner programmers?

For someone just starting to program, would you recommend using vim/emacs, or should you use some IDE? Like are vim/emacs better suited for more advanced users than for beginners? I'm just wondering because I'm trying to get some of my friends to program. ...

How to use VIM to remember open files between sessions?

I use VIM as my main text editor here at work and I often have 10-15 files open at once in a couple of windows with several tabs, each of which has its own split windows. I love using VIM, but I hate having to re-do my entire set-up every time the dev server gets bounced or my machine crashes. Is there a way to get VIM to remember a setu...

Vim 'autowriteall' option only for specific buffers

The 'autowriteall' option makes Vim save all buffers when quitting. I want to be able to use this option only for one specific buffer (a temp file which will be discarded soon) but not for the other buffers. How do I get Vim to automatically save changes only for one specific buffer? ...

How to override default syntax highlight in vim?

Hello. In VIM, i need to perform a simple task - highlight "(" and ")". I can do this easily by issuing two commands: :syn match really_unique_name display "[()]" :hi really_unique_name guifg=#FF0000 But if i add same commands (without ':' of course) to empty .vimrc and restart VIM - "(" and ")" are not highlighted anymore in .cpp fi...

how to make vim recognize CJK characters and render them larger than ASCII?

Hello there, I am using vim to work on both Chinese and Western text. The default font size is okay for Western text, but the Chinese characters, while readable, are too small for my taste. Can I tell vim to render CJK fonts with, say, 14pt while not affecting the font size of all other text? Thanks for your ideas/solutions! Guba ...

To comment out matches in Vim

I would like to comment out each line which has the following match ^.*pdf You need to somehow consider the situation by globbing. I try to make an object of the match by brackets. I run unsuccessfully the following commands %s/^(.*pdf)/^%$1/ and %s/^(.*pdf)/^(%*$1)/ and %s/^(.*pdf)/^%\$1/ How can you comment out the matches...

What is your most productive shortcut with Vim?

I've heard a lot about Vim, both pros and cons. It really seems you should be (as a developer) faster with Vim than with any other editor. I'm using Vim to do some basic stuff and I'm at best 10 times less productive with Vim. The only two things you should care about when you talk about speed (you may not care enough about them, but yo...

How to force VIM/GVIM show last buffer line at the bottom (instead of top)?

If using mouse wheel (or scrollbar) to scroll to the bottom of current buffer, then VIM allows to "scroll bellow" the bottom of the file. So that the last line appears at the top of current buffer. This brings much pain for me as for VIM newbie used to deal with other editors (especially MS VS). Is there any way to disable "scrolling ...

Should i use gVim, or the terminal?

Hello Stackoverflow! I'm currently starting to learn how to use Vim, and it seems pretty cool. However, I'm kinda wondering if I should use the terminal for my editing, or gVim? I'm running Linux (Ubuntu). ...

Keep the cursor column while swapping buffers in vim

In vim, if you swap buffers with :bn and :bp, the cursor stays on the same line, but not on the same column. Is there a way to keep it on the same column as well ? ...

VIM: RSync on save

Hey all, I'm looking for a way to map the :w command so that when I use it, it will rsync the current directory and save the file in question. Ideally, the response generated by the rsync command should be returned in vim, but not in the the current file, but rather as a tooltip or something. I managed to achieve this in TextMate and a...