background preloader

Vim

Facebook Twitter

Creating your own syntax highlighting file. [ Home - Syntax Files - Rxvt - Dead Keys - Compiling - Ispell - Download ] First, you need a .vimrc file in your home directory. You can use mine as a guide if you want. The important lines with respect to syntax highlighting are " get syntax highlighting let mysyntaxfile = "$VIM/mysyntax/mysyntax.vim" syntax on This assumes that you did set the environment variable VIM to point to the vim installation directory. Now you have to create the mysyntax.vim file. That's all there is to it. If you want to create a new syntax file for a new language, you need to do the following: Create a new filetype in your vimrc file. My vi/vim cheatsheet. Cursor movement h - move leftj - move downk - move upl - move rightw - jump by start of words (punctuation considered words)W - jump by words (spaces separate words)e - jump to end of words (punctuation considered words)E - jump to end of words (no punctuation)b - jump backward by words (punctuation considered words)B - jump backward by words (no punctuation)0 - (zero) start of line^ - first non-blank character of line$ - end of lineG - Go To command (prefix with number - 5G goes to line 5) Note: Prefix a cursor movement command with a number to repeat it.

My vi/vim cheatsheet

For example, 4j moves down 4 lines. Insert Mode - Inserting/Appending text i - start insert mode at cursorI - insert at the beginning of the linea - append after the cursorA - append at the end of the lineo - open (append) blank line below current line (no need to press return)O - open blank line above current lineea - append at end of wordEsc - exit insert mode Editing Marking text (visual mode) Visual commands Cut and Paste Exiting. Vim Text Objects: The Definitive Guide. To edit efficiently in Vim, you have to edit beyond individual characters.

Vim Text Objects: The Definitive Guide

Instead, edit by word, sentence, and paragraph. In Vim, these higher-level contexts are called text objects. Vim provides text objects for both plaintext and common programming language constructs. You can also define new text objects using Vim script. Learning these text objects can take your Vim editing to a whole new level of precision and speed. Structure of an Editing Command In Vim, editing commands have the following structure: The number is used to perform the command over multiple text objects or motions, e.g., backward three words, forward two paragraphs. The command is an operation, e.g., change, delete (cut), or yank (copy). The text object or motion can either be a text construct, e.g., a word, a sentence, a paragraph, or a motion, e.g., forward a line, back one page, end of the line. Plaintext Text Objects Words Lorem ipsum dolor sit amet...

Learn to speak vim - verbs, nouns, and modifiers! Posted 16 December 2011 @ 12pm in vim Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms learn some verbs: v (visual), c (change), d (delete), y (yank/copy). these are the most important. there are otherslearn some modifiers: i (inside), a (around), t (till..finds a character), f (find..like till except including the char), / (search..find a string/regex)learn some text objects: w (word), s (sentence) p (paragraph) b (block/parentheses), t (tag, works for html/xml) there are others To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences delete the current word: diw (delete inside word)change current sentence: cis (change inside sentence)change a string inside quotes: ci” (change inside quote)change until next occurrence of ‘foo’: c/foo (change search foo)change everything from here to the letter X: ctXvisually select this paragraph: vap (visual around paragraph)

Learn to speak vim - verbs, nouns, and modifiers!