vim

Custom folding for CSS in Vim

I came upon this custom folding for CSS in Vim and inspired by it I was trying to make my own with slightly different result in mind. I had to give up as I couldn't make search patterns work in folding function. No surprise to me as I'm rather a Vim beginner :) Any help to achieve the following will be much appreciated. I use empty li...

How can I fold YAML items in VIM?

I have a YAML formatted text file, and would like to define custom folding for VIM, but I'm not sure how to go about it (despite reading the VIM documentation for folding). The file consists of YAML "documents", like so: --- title: My Title attr1: value1 attr2: value2 --- title: Next Item attr1: value3 --- title: One More Item ... I ...

Vim's omnicompletion fails with "from" imports in Python

Omnicompletion for Python seems to fail when there is a "from" import instead of a normal one. For example, if I have these two files: Test.py: class Test: def method(self): pass main.py: from Test import Test class Test2: def __init__(self): self.x = Test() If I try to activate omnicompletion for self.x......

VIM: How to pass arguments to functions from user commands?

I am trying to create a user-defined command in VIM that takes one argument and calls a function with the user supplied argument. Seems simple but I am unable to get it to work. Here is the code from my foo.vim plugin: function! s:MyFunc(myParam) do something endfunction command! -nargs=1 MyCommand call s:MyFunc(myParam) When I ...

Format code with VIM using external commands

Hi, I know that using VIM I can format C++ code just using gg=G Now I have to format 30 files, so doing it by hand becomes tedious. I had a look how to do it passing external commands to VIM, so I tried vim -c gg=G -c wq file.cpp but it does not work. Can you give me a hint? Thanks ...

How do you paste with vim without code being commented?

Dumb question, right? Literally can't figure this out. Everytime I paste in vim, every line is commented out. Is there a way around this? ...

Indenting in VIM with all the files in Folder

I have a folder containing hundreds of TTL (TeraTermLanguage) files. Now I wanted indent all these files. I have created teraterm.vim for indentation and I open a file using VIM and do "gg=G" and whole file gets indented properly. But is there any way, where I can indent all the files in folder. I wanted to do with help of Shell. ...

adding characters at the start and end of each line in a file

What is the best way to add some characters at the start and end of each line? something like quotes etc? Can it be done using Vim, or some other way? ...

vim - write buffer content to stdout

Is there any chance to write the content of the current vim buffer to stdout? I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the modified content. (on Linux/Unix) Added: Is it possible that a plugin/script - that act on quit or save put the buffer content to stdout? ...

handling special characters when executing named buffers in vim

I've used vi for decades, and am now practicing using vim, expecting eventually to switch to it entirely. I have a number of questions, but I'll start with the one that troubles me most. Something I have long done in vi is to type a bottom-line command into the file I am editing, yank it to a named buffer (e.g., using the keystrokes "ay...

Linux shell (bash) on vi's splitview

Hi all, I've been searching with no results for an integration of bash inside vi, as featured in emacs; the problem is: I have vi open with 2 views, one open with :split command, and I want to use bash through the second view, while I'm editing a file in the first; if I do :sh while editing the second view, the whole session pauses and a...

Javascript indentation in VIM

I'm trying to get VIM to indent Javascript with the '=' and related commands. When I try to auto indent the following, for example: new function($) { $.fn.setCursorPosition = function(pos) { if ($(this).setSelectionRange) { $(this).setSelectionRange(pos, pos); } else if ($(this).createTextRange) { ...

Apply regular expression substitution globally to many files with a script

I want to apply a certain regular expression substitution globally to about 40 Javascript files in and under a directory. I'm a vim user, but doing this by hand can be tedious and error-prone, so I'd like to automate it with a script. I tried sed, but handling more than one line at a time is awkward, especially if there is no limit t...

Delete Key is changing letter case in Vim

I'm trying to get into Vim. I'm running it in the terminal on OS X. Anytime I hit the delete key, it simply changes case of that letter instead of deleting it. When I SSH into my server and use Vim there, it deletes normally. Any ideas what may be going wrong? Thank you! ...

Achieving Netbeans-style line moving and duplicating in VIM

In Netbeans, Ctrl-Shift-Up/Down duplicates the current line or selection and Alt+Shift+Up/Down/Left/Right moves the current line or selection. How can this be achieved in VIM 7? So far, I'm able to get Alt+Shift+Up/Down working using these mappings: :nmap <A-S-up> :m .-2<Enter> :imap <A-S-up> <Esc>:m .-2<Enter>gi :vmap <A-S-up> :m .-2...

Disable ESC as meta in emacs viper mode?

Hey all, I'm a long-time vim user trying to make the switch to emacs. I'm using viper-mode in emacs and I keep typing ESC (to get out of insert mode) and then a key (say, j). I type fast and often hit them at the same time. Emacs then thinks I'm hitting META-j and runs a function which I do not intend. I like using option as meta and d...

How can I visualize per-character differences in a unified diff file?

Say I get a patch created with git format-patch. The file is basically a unified diff with some metadata. If I open the file in Vim, I can see which lines have been modified, but I cannot see which characters in the changed lines differ. Does anyone know a way (in Vim, or some other free software that runs on Ubuntu) to visualize per-cha...

How to update Vim to color-code new html elements

I am wondering how I might set vim to color the new html5 elements (ie "canvas" and "video") as it does with the existing "script", "body" elements (or reserved words in other languages like python's "def") etc. Current version is from MacPorts typically used in a terminal emulator. ...

How to change the cursor keys in VIM

I'm trying to change the cursor keys in VIM from the normal h,j,k,l to the home position for typing j,k,l,;. Any suggestions on how to do that? Thanks in advance. ...

Disabling autocommenting for all filetypes

I turned on filetype plugin for some rails vim plugins I added, but a side effect of this seems to be that now autocommenting has been enabled in all filetypes (for instance, if I start a line with #, the next line, either by Enter in insert mode or O, etc. to enter insert mode, will also get a #). I found a guide to disabling the auto-...