background preloader

Best of VIM Tips, gVIM's Key Features zzapper

Best of VIM Tips, gVIM's Key Features zzapper

Resizing Vim window splits like a boss - Read'n'Code - Flaviu Simihaian's Blog If you’re using Vim as your text editor (if you’re not, these videos will convince you), you’re probably using window splits. If you’re using window splits, you probably wished you had a quick way to resize them. I recently watched Gary Bernhardt’s video on VIM File Navigation, and got inspired to research this problem. So, set the following in your ~/.vimrc: This will make sure all splits will be at least 5 lines (which is enough for reference), and the current window will be 30 lines. You can increase or decrease the size of a window by one line with Ctrl-w + - and Ctrl-w + +. That probably makes no sense. As for navigation, I’m using these mappings to move between splits with Ctrl-w + - and Ctrl-w + *+: Also, if you want to make all windows equal, use Ctrl-w + = Check this out for similar nuggets.

Start - Synchronizing plugins with git submodules and pathogen - Pentadactyl Synchronizing plugins with git submodules and pathogen If you use Vim on muliple machines, it can be difficult to keep your configuration files synchronized across them. One solution is to put your dotfiles under version control. Keep your dotfiles in git The following instructions assume that your home directory contains a .vimrc file, a .vim directory and a .gvimrc file (optional). Move the .vimrc and .gvimrc files into the .vim directory: mv .vimrc ~/.vim/vimrc mv .gvimrc ~/.vim/gvimrc Create symbolic links so that ~/.vimrc points to the ~/.vim/vimrc file: ln -s ~/.vim/vimrc ~/.vimrc ln -s ~/.vim/gvimrc ~/.gvimrc Change to the .vim directory, and initialize it as a git repository: cd ~/.vim git init Create a README file, and paste installation instructions into it (see example README). Add all files, and make an initial commit: git add . git commit -m "Initial commit" Keep your plugins in git Pathogen.vim The pathogen plugin makes it possible to cleanly install plugins as a bundle. Updates

Writing Vim Plugins / Steve Losh Posted on September 6th, 2011. A while ago I wrote a post about switching back to Vim. Since then I've written two plugins for Vim, one of which has been officially "released". A couple of people have asked me if I'd write a guide to creating Vim plugins. Other People Who Know More Than I Do Writing two decently-sized Vim plugins has given me some experience, but there are a lot of people that know far more than I do. Tim Pope The first is Tim Pope. It would be awesome to read a guide on the ins and outs of Vim scripting by him. Scrooloose The other person that comes to mind is Scrooloose, author of NERDTree, NERDCommenter and Syntastic. His plugins are large and full-featured but work incredibly well, considering how tricky and painful Vimscript is to work with. Be Pathogen-Compatible It's 2011. yourplugin/ doc/ yourplugin.txt plugin/ yourplugin.vim ... This will let users use Pathogen (or Vundle) to install and use your plugin. Please, For the Love of God, Use normal! normal! When to Map Keys

Vim eighteen months on - shapeshed I switched to Vim for editing text about 18 months ago. Here's an overview of my experience. Goodbye TextMate? About 18 months ago I made the decision to give Vim a go as my primary text editor. I had been using vi extensively for server admin work for a number of years so I wasn't a total noob. TextMate was my default editor and broadly I was happy with it but decided to give Vim a go. Baby steps I started out with baby steps, looking back to TextMate and doing all of the common things a switcher does, especially looking for TextMate's features in Vim. Many people recommend using MacVim to ease the transition. Installation of MacVim via homebrew on OSX is easy brew install macvim MacVim works like a standard application so you don't need to edit directly in the terminal and comes with many common keyboard shortcuts that you'll likely be used to. The setup phase As with with many things in UNIX you get back what you put in. Learn as you go Vim does take time to learn. :help lowercase Now

vim - Vim as XML Editor: Setup - Pentadactyl Again, this is just one way of setting things up. TMTOWTDI ;) Your local environment is likely to be different, as well as your preferences, and the tools evolve. I'll give a short overview of what I use; please refer to the documentation of the respective tool for instructions on how to best set things up. If you experience problems with any of the tools featured below please file bug reports directly to the respective project. Linux Here's my .bashrc: ~/.bashrc Often it helps to do source .bashrc after having modified .bashrc and after having created new command scripts. Windows When creating batch files on Windows (file name suffix .bat) don't forget to make sure that the file format is set correctly. The vimrc file is the place where you set your preferences. vimrc The latest version is online at www.pinkjuice.com/vim/vimrc.txt. For example there is let mapleader = "," and nmap <Leader>l <Leader>cd:%w ! which means that whenever I want xmllint to validate the buffer I do , l. home Home Manual man #!

~ Transactions Pending Literature adds to reality, it does not simply describe it. It enriches the necessary competencies that daily life requires and provides; and in this respect, it irrigates the deserts that our lives have already become. – C. S. Lewis What are Text Objects? Even if you are a newcomer to vim, you’re likely familiar with the concept of a text object. One of the most commonly-used examples is iw, which is short for or inner-word. In the same way that “literature adds to reality”, text objects add to vim’s ability to describe transformations on text. Simple Text Object Example In order to make a new text object, you should map both the visual-mode mapping as well as the operator-pending mapping. Text Object inner-line Here is a very simple example that creates the text object il for inner-line: " "in line xnoremap <silent> il :<c-u>normal! In order to fully understand the mappings, it might be useful to review Markzen’s pun-filled article, “For Mappings And A Tutorial”. inner-line LHS: il

Mastering the VI editor Date: 15/06/2012 I decided to republish the article below after trying to visit the original (to share the link with friend) and discovering it no longer existed. The original was written by Ben Y. Hopefully by replicating the original here, I can help a few more people find benefit from it. Download/View PDF Introduction The VI editor is a screen-based editor used by many Unix users. Conventions In this tutorial, the following convention will be used: ^X denotes a control character. Before You Begin The VI editor uses the full screen, so it needs to know what kind of terminal you have. TERM = (vt100) If you know your terminal is a vt100 (or an emulator that can do vt100), just hit return for the terminal type when you log in. If you make an error when you log in and type the wrong terminal type, don't panic and log out. First, tell your shell what type of terminal you have. set term=vt100 For Bourne Shell (/bin/sh) or Korn Shell (/bin/ksh), the commands are the following: export TERM TERM=vt100

~ For Mappings And A Tutorial On The Genealogy of Modality What makes Vim so different from other editors is, arguably, its rich set of motion commands. Once you can move around with precision, you not only gain time, as you do not need to reach for the mouse, but you can also turn pretty much every modification into tiny “programs”, either to accomplish ad hoc tasks via recorded macros, or to address more general cases, thanks to commands, functions–and mappings. A mapping is the binding of a key or a sequence of keys, called the left-hand side (LHS), to a series of keystrokes, the right-hand side (RHS). Obviously, since alphanumeric keys are used to write “editing programs”, there is a need to separate “programming mode” where the user hits dw to delete until next word, from “insertion mode”, where the user just wants to type text and not execute programs. So, if Vim is programming, custom mappings are no less than its user-defined functions. Maps. The general syntax to create mappings is: GG no RE Silence, RHSling

Why, oh WHY, do those #?@! nutheads use vi? The VI Gang Sign by Jon Beltran de Heredia, May 16th, 2007 Yes, even if you can't believe it, there are a lot fans of the 30-years-old vi editor (or its more recent, just-15-years-old, best clone & great improvement, vim). No, they are not dinosaurs who don't want to catch up with the times - the community of vi users just keeps growing: myself, I only got started 2 years ago (after over 10 years of being a professional programmer). Friends of mine are converting today. Yes, there are definite reasons why the vi/vim editing model is just superior to any other out there. Misconception #1: modal editing The first time you stumble into vi or vim, you are shocked and disgusted that you have to use 'i' to start typing text. Turns out, this is just a completely wrong way to use vi or vim. Let me explain the philosophy behind this. One good benefit of this is that the '.' command repeats the last complete, combined editing command (not movement commands). And now we come to insert commands.

~ You Should Be Using Tags In Vim I love you; you complete me. – Dr. Evil I first came to Vim by recommendation. I was looking for a good Python IDE (at the time I was new to the language) and one recommendation was to use Vim with a variety of plugins added on top. That Vim could do a lot of the things I thought only an IDE could do came as a bit of a shock. So how was I directed to achieve powerful programming completions in Vim? What I found was Vim itself. Did you know that Vim has built-in facilities for completions? Completion in Vim Completion in Vim is powerful, but not necessarily straightforward. Completion can be done for: 1. Vim is smart enough to pull completion data from a variety of sources, but in turn expects users to know which source will provide the best answer and to invoke the correct keymap to draw the desired completions. The first thing one should do when trying to learn Vim’s completion system is to disable any completion plugins and learn these keymaps. Manually Automatically Tying It All Together

Beginner's guide to Vi Improved (vim) Jesse Goerz jwgoerz@users.sourceforge.net Copyright © 2002 Jesse Goerz, NewbieDoc project. This manual is free software; you may redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. You should have received a copy of the GNU General Public License with your Debian GNU/Linux system, in /usr/doc/copyright/GPL, or with the debiandoc-sgml source package as the file COPYING. 1. This document will cover the console version of vim from Debian stable. Learning vim can be a bit of a trial but it is well worth it in the long run. No introduction to vim would be complete without a warning. If it is so irritating why would you want to learn how to use it? 4. To get more information on modes type: 4.2.

rktjmp/lush.nvim: Define Neovim themes as a DSL in lua, with real-time feedback. Getting Started with Vi Most people who are getting started with Linux or UNIX today already know how to use graphical WYSIWYG (what you see is what you get) editors, with heavy use of the mouse, icons and pull-down menus. When they first encounter the traditional UNIX/Linux editor, vi, it may seem awkward and not very powerful, but the opposite is true. As with graphical editors, you can select a range of text and execute a command to make changes, move the cursor by indicating where you want it to be and insert text by typing at the keyboard. The difference is that vi doesn't use the mouse; you use the keyboard to specify changes or move the cursor. In order for the entire keyboard to be available for commands, vi has separate command and insert modes. Modes can be confusing at first. Most new vi users learn only a few basic commands: the arrow keys, i for insert, x to delete a character, dd to delete a line, :wq to save and exit and perhaps a few others. The first command to learns in vi is i.

Vim's useful lists — David Winterbottom A good understanding of Vim’s various lists is a massive productivity boost — it’s taken me many years of Vim use to truly appreciate this. This post summarises some of Vim’s lists, detailing their purpose and how to make the most of them. Contents: Quickfix list A global list of locations populated via one of these commands: :vim[grep] — search using Vim’s native functionality. Quickfix list commands start :c — here’s some useful ones: :cw[indow] — Open the quickfix window if it’s non-empty. Vim remembers the last ten quickfix lists; you can navigate between them with: :col[der], :cnew[er] — Go to the older/newer quickfix list. This is powerful: it allows building a tree of searches, which is a useful debugging pattern when exploring a codebase. More at :help quickfix. Tip: Use mappings for faster browsing Since you’ll use them a lot, define convenient mappings for :cnext and :cprev. [q, ]q — :cprevious, :cnext[Q, ]Q — :cfirst, :clast[<C-Q>, ]<C-Q> — :cpfile, :cnfile I use: function! then use:

Related: