vim

How to fix broken automatic indentation in vim

Hi, I am trying to use vim 7.2 (on Windows XP) to automatically indent and format some VHDL and Matlab code. To do so I am trying to use the "gg=G" command. However this does not work properly. The code is not properly indented at all. To give you an example, I had the following source code, which was already properly indented: % This...

How do I fix '/bin/bash/: command not found' in vim w/ rails-vim plugin?

I'm using gvim and rails.vim and getting the following error when attempting to run :Rake from within a migration: :!rake db:migrate VERSION=20100427002644 2>&1| tee /tmp/v436868/11 /bin/bash/: rake: command not found I'm not sure how to troubleshoot this. What can I do to fix this? Edit: If i run rake --version from the terminal i...

How to correctly highlight cursor line in VIM?

Hello. VIM can be configured to highlight current line via :hi cursorline guibg=green and set cursorline commands. But if I enable tabs display via: :hi specialkey guifg=grey guibg=grey :set listchars="tab" :set list Cursor line highlight will corrupt tabs display: Any hints how i can avoid corruption so may tabs are highlighted w...

Vim: How to handle newlines when storing multiple commands in registers?

I have a file where I store snippets of vim commands. When I need a snippet, I yank it and then execute it with @". The snippets are stored as a script, one line per command, like this: :s/foo/bar/g :echo "hello" :s/1/2/g Edit: I removed normal mode commands from the example, as they were not part of the problem. Now this procedure d...

VIM Loses Undo History when changing Buffers

If I'm working in a file, change to another buffer, and then change back, I have lost my undo history. File1.txt - make a bunch of changes & save. Open new buffer - :e test.txt Switch back to File1.txt - :b# Undo history is gone. Any work arounds for this? ...

Launching Vim via Lua

I'm writing a simple little Lua commandline app that will build a static website. I'm storing my fragments in a sqlite database. Retrieving the data from the db is straightforward as is saving it; my question comes from editing the data. Is there an elegant way to pipe the data from Lua to vim? Can vim edit a memory buffer and return it...

auto indent in vim string replacement new line?

I'm using the following command to auto replace some code (adding a new code segment after an existing segment) %s/my_pattern/\0, \r some_other_text_i_want_to_insert/ The problem is that with the \r, some_other_text_i_want_to_insert gets inserted right after the new line: mycode( some_random_text my_pattern ) would become mycode...

Execute a command under the cursor in VIM

1. How can I execute a command in vim, under the cursor. (word) We know that Shift+k is used to open a man page under the cursor. I want to execute the command instead of opening the man page. [OR] 2. How can I take the current word under the cursor in VIM? ...

How do I delete a word when the cursor is in the middle of the word ?

I am working in VIM and I just want to know is it possible to delete a word when the cursor is in the middle of that word (or some where it is other than the beginning or end). Thanks in Advance :-) ...

Removing contiguous duplicate lines in vi without sorting

This question already addresses how to remove duplicate lines, but enforces that the list is sorted first. I would like to perform the remove contiguous duplicate lines step (i.e. uniq) without first sorting them. Example before: Foo Foo Bar Bar Example after: Foo Bar ...

How to retrieve the currently searched for text in vim?

For example, I have some code and I use "*" to search for something within that code. Not finding what I want in that file, I'd like to use something like ack or grep to search for it within the local directory. I know I can do :! ack whatever to do the search from within vim, but what I'd like to know is is there a way to replace whatev...

How do you enable file specific tab indent settings in VIM?

I believe there is a method to write a comment in a file that vim will use to override default tabbing and indent values. Can someone point me to information about this feature and how to use it? ...

How can i attach to a process using gdbvim?

Hi, I use Vim as primary IDE for programming, with some plugins i have a good environment but for a single point: debugging. I have recompiled Vim to use vimgdb, and it works, but the problem is that i need to attach to a process started by a root user so i have to use sudo to do it.... How can i do this with vimgdb? Thanks in advanc...

AutoIndent for JavaScript in Vim that understands Semicolon Insertion

I don't end my JavaScript statements with semicolons when newlines will work. No flames, please. My question is, is there an automatic indentation package for vim that will work? Here is an example of how dumb it is: $(function(){ var foo // code starts here, // The following line breaks things, but adding a comment to it fix...

How can I include the period (.) in Vim's search and replace command? (replacing .html extensions)?

When I do: /.html Vim looks for html I would like to replace all the .html with .php Something like this: :%s/html ext/php ext/g ...

How to capture shift-tab in vim

I want to use shift-tab for auto completion and shifting code blocks visually. I have been referring to Make_Shift-Tab_work . That link talks about mapping ^[[Z to shift-tab . But i don't get ^[[Z when i press shift-tab. i just get a normal tab in that case. It then talks about using xmodmap -pke | grep 'Tab' to map tab keys. Accordin...

Is there an extension or mode in Emacs similar to surround.vim?

Surround.vim is a nifty vim extension that allows you to surround blocks of text with , brackets, braces, and pretty much any arbitrary "surround" character. It supports paragraph and word surround, but I frequently use it in visual mode. I'm playing around with Emacs and wondering if there's something similar; something that will let me...

vim c++ break line

Hello: How can I break long lines when writing c++ code in vim? For example, if I have something like 56 fprintf(stderr, "Syntax error reading recursion value on 57 line %d in file %s\n", line_count, filename); I get the following compile errors: :56:25: warning: missing terminating " character :56: error: missing te...

Can Visual Studio manage function prototypes for me in C++ header files?

In C++, the common practice is to declare functions in header files and define them in cpp files. This leads to always having two copies of every function's prototype. Then whenever I want to change a function's name/return value/parameter, I have to manually change it in both files. This seems unnecessarily tedious and there must be lot...

Vim & Java: add java import statements automatically

The tip. The errors are "E349: No identifier unders cursor", "E433: No tags file" and "E426: tag not found: public". I feel them unrelated or I cannot understand their message. I have the code in "~/.vimrc" and pressed "F1", "F9" and "ESC". A related tip but more advanced. so how can I add Java import statements automatically in Vim? [A...