vim

How do I get vim's :sh command to source my bashrc?

Whenever I start a shell in vim using :sh, it doesn't source my ~/.bashrc file. How can I get it to do this automatically? ...

VIM like tools and softwares Collection

Hi All: I've used VI(M) for over 2 years, and I really love its easy navigation and keyboard orientation. So except VI(VIM, gvim), I try to find more VIM-like tools(softwares) to benefit more. And I've got the following findings: apvlv: for pdf reading(really impressive) VIM like chrome browser plugin (and firefox has a similar vimper...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the problem is that I would prefer it if it only worked on certain file types. Basically, any programming language should be highlighted and ...

How can I create a mapping with control and a function key in Vim?

I would like to have a mapping to quickly quit all buffers, for use when I'm vimdiffing a lot of files. Control and a function key together proved a good safety, so that I don't accidentally hit this combination, unintentionally leaving Vim. I tried the following mapping: map <C-F10> :qa<CR> To no avail. If I ditch the control, I c...

Opening files in the same folder as the current file, in vim

In vim, when I have a buffer open, I often need to load another file in the same directory that file is in, but since I don't usually cd into it, the pwd is a parent folder, so I have to retype the path every time. Is there a shortcut for this? or a way to change the pwd to the directory the file is in? example: cd /src vi lib/foo/file...

valid string in vim?

Hi, Handy shortcut "*" - which reads the "string" under the cursor and goes to the next place it appears. can some one clarify what comprises a valid "string" in vim. I am facing a problem that when i use "*" with cursor on word "function" on the following line function(val) {} it selects the text "function(val)" and searches for t...

Retain undo buffer after quitting VIM?

Hello, I'm wondering if it is possible to retain VIM's undo buffer after quitting. For example, I'd like to make some edits to a file, save & quit (:wq), then reopen the file and still be able to hit 'u' to undo the edits. Is this possible in VIM? ...

Can you mass edit all files returned in a grep?

I want to mass-edit a ton of files that are returned in a grep. (I know, I should get better at sed). So if I do: grep -rnI 'xg_icon-*' How do I pipe all of those files into vi? ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread across many lines? ...

Vim go to last edited line

I'm aware of `. command that goes to last edited line. Is there a way to go further in the editing history? I often accidentally insert something while browsing the file, undo, but then `. will not bring me where i want anymore. ...

How can I delete all lines that do not begin with certain characters?

I need to figure out a regular expression to delete all lines that do not begin with either "+" or "-". I want to print a paper copy of a large diff file, but it shows 5 or so lines before and after the actual diff. ...

How can I map ":vsplit ." to <F7> in Vim?

I'd like to create a mapping for :vsplit .. I tried adding this to .vimrc... nmap <F7> verticalsplit . However, when I hit <F7> it goes into insert mode and inserts "calsplit .tttt". (Why "tttt"?) ...

Scrolling inside Vim in Mac's Terminal

I've been googling around trying to figure out if it's possible to use my mouse wheel to scroll while inside Vim in Mac's Terminal, with no luck. It seems as if only X11 or iTerm support this. Before I give up, I thought I'd try the geniuses here to see if anyone knows a way to do this. So, does anyone know if I can set that up? Or sho...

Jumping back to a previously opened file in vim

I apologize if this has already been asked; I did a few searches both here and on Google and I can't find the answer to my question. While using Vim I'll sometimes want to look at a function definition or a struct definition, so I'll use C-] to jump to it. However, there are a few problems I run into. First off, I don't know how to jum...

Do you use VIM/Emacs/Terminals to develop C/C++? What kind of projects is this practical for?

For those who are using vim/emacs/terminals,etc (ie, not an IDE proper) what sort of projects are you working on? Are they big? Production? Are these the tools you use at work? Or mostly for smaller things...or big things broken into small things? Sorry...enough questions. I ask because I'm studying computer science right now, and am su...

Using vim's `gqap' sometimes indents unusually

For the life of me, I cannot figure out the cause of this: when writing in LaTeX documents, I like to keep my line width to maximum of 80 characters. As such, I will execute the vim command gqap and vim will automatically re-wordwrap the paragraph I am writing. For example, it will cause a long line to become many shorter ones: Lorem i...

Vim: Traversing text in Insert mode

While in Insert Mode in Vim, is there any way to traverse the text (like moving some characters forward and backward) other than using the arrow keys ? This is because obviously if you press h, j, k and l while in Insert mode, the actual characters are printed on screen instead of moving through the text. The way I'm doing it atm is ha...

how to unindent in vim without leaving edit mode?

Hi all, I'm writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block. Normally I can just type << to unindent, but it takes too many keystorkes, anyone have a better idea? ...

VIM: display custom reference bar on top of window

I would like to set up a vim environment for basic HTML edit to be used by someone else. For this I'd like to set up a quick reference bar to be shown on top of the window with things like | <F1> | <F2> | <F3> | ... | <br /> | <hr /> | bold | ... and so on. Can this be done? ...

Autowrite VIM buffers after <alt-tab>

How can I configure vim to autowrite buffers after switching with alt-tab to another application? ...