
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
vi/vim tips Editing with vi/vim is a fairly wide subject. This section contains some interesting information for vi/vim users, as well as for those learning to use vi/vim. It also contains vi/vim related stories, such as how & why I began using vim (in 2005!). Some of the articles were initially published as blog posts, and the links below point to the original blog post. If you want to find more content related to other matters, such as developing a compiler and virtual machine, extending Visual Studio, using the Cheetah template engine to structure a web site, etc... visit the main NGEDIT articles section. Articles Why, oh WHY, do those nutheads use vi? Graphical cheat sheet & tutorial [March 2006] How to start learning vi/vim [Sept 2005] Why start using vi/vim/ViEmu?
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 #!
Power Vim Usage: Tips & Tricks for Everyday Editing Tips & Tricks for Everyday Editing Smylers UKUUG Linux 2004 Conference • 2004 August This view lists all the slides from the talk in a continuous format. The slides are also designed to be viewed as a slideshow from this file with Mozilla or a compatible browser. 1 Intro text editing: crops up all over Linux once good at it, find many uses for it Vim: powerful — potential for great efficiency Emacs and other VI variants also good this talk: tips — features & customizations fast, random, dull to encourage reading the notes work in progress 2 Learning Vim Vim is far too big to learn quickly probably too big to learn slowly learning it as an extension of VI is often not helpful The only way to get the hang of Vim is a bit at a time — learning some things you can make use of, getting comfortable with them, then learning some more. Some of the most useful Vim features don’t require any VI knowledge. 3 Moving About Capital F is similar to f but moves left instead of right. 4 Visual Mode
~ 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
VIM Adventures ~ 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.
Vim Regular Expressions 101 ~ 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