background preloader

Efficient Editing With vim

Efficient Editing With vim

DeepaMehta -- Homepage Vim Commands Cheat Sheet How to Exit Editing a File Inserting Text Inserting a file Deleting Text Changing (or Replacing) Text Substituting The arguments that you can use for the substitute commands: [c] Confirm each substitution. Copying and Moving Text Undo/Redo/Repeat Moving Around Basic motion commands: k These commands move over words or WORDS. A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, A WORD consists of a sequence of non-blank characters, separated with white space. Screen movement commands Marks Searching Selecting Text (Visual Mode) To select text, enter visual mode with one of the commands below, and use motion commands to highlight the text you are interested in. The operators that can be used are: ~ switch case d delete c change y yank > shift right < shift left ! How to Suspend

Vim Cookbook by Steve Oualline This is the Vim cookbook page. It contains short recipes for doing many simple and not so simple things in Vim. You should already know the basics of Vim, however each command is explained in detail. Each set of instructions is a complete package. Contents Character twiddling If you type fast your fingers can easily get ahead of your mind. To swap two characters, for example "e" with "h", put the cursor on the cursor on the "e" and type xp. The "x" command deletes a character (the "e") and the "p" pastes it after the cursor (which is now placed over the "h".) Interactively replacing one word with another (n. method) Suppose you want to replace every occurrence of the word "idiot" with the word "manager". Here's what you do: Repeat steps 4 and 5 until you have replaced all occurred. The Virgin What!? Interactively replacing one word with another (command line method) Execute the command: :%s/\<idiot\>/manager/gc The parts of this command are: Use the command: :%s/\<idiot\>/manager/g

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. Heck, most vi users were not even born when vi was written! 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. And now we come to insert commands. Example #1: the wonderful dot command Let's see a concrete example.

Graphical vi-vim Cheat Sheet and Tutorial Learning vi or vim is not easy. But it doesn't have to be that difficult, either. It is, in any case, faster, more powerful, and more productive than editing with any other editor, so you would do very well in investing the time and effort to learn it. Being a vi lover myself, I came up with the idea of providing a graphical cheat sheet for those learning vi or vim, and I also found out it was a very good way to structure a tutorial. Here are the results for your learning enjoyment (or your colleagues'). By the way, I recently published the definitive article explaining why vi/vim editing is so much better than regular editing. Graphical cheat sheet This is a single page describing the full vi/vim input model, the function of all keys, and all major features. Graphical cheat sheet based tutorial The tutorial above is structured in 7 lessons that cover the major commands in vi/vim. Notes With the single exception of the external filter feature ("!") Relevant links Why, oh why, do those #?

Vim: Seven habits of effective text editing Bram Moolenaar November 2000 If you spend a lot of time typing plain text, writing programs or HTML, you can save much of that time by using a good editor and using it effectively. This paper will present guidelines and hints for doing your work more quickly and with fewer mistakes. Part 1: edit a file 1. Most time is spent reading, checking for errors and looking for the right place to work on, rather than inserting new text or changing it. Quite often you will want to search for some text you know is there. If you see a specific word and want to search for other occurrences of the same word, use the * command. In structured text there are even more possibilities to move around quickly. Use % to jump from an open brace to its matching closing brace. There are many more, of course. There are three basic steps: While you are editing, keep an eye out for actions you repeat and/or spend quite a bit of time on. Let's use an example to show how it works: 2. 3. Part 2: edit more files 4. 5. 6.

Faster PHP Apps—Profile Your Code with Xdebug Object-oriented programming is well and truly in fashion, and PHP is no exception. So you’ve adopted the proper design patterns, built your site on the latest PHP framework, and have your database access abstracted so far that you’ve forgotten SQL. What’s Going On? When you first move towards object-oriented programming, the first thing you might notice is that you can give yourself a headache trying to follow the execution path through your code and the framework it’s built on. The next thing you might notice is that your site isn’t any faster – in fact perhaps it’s slower than it was. So we’ve got potentially slower code, and we can no longer just open up our simple PHP script and follow its execution from the top of the file to the bottom. Xdebug Xdebug 2 (currently beta – I’m running 2.0.0RC3) is an indispensable PHP extension which provides various ways of debugging and analysing your code on your development server. WinCacheGrind KCachegrind Less Grinding, More Caching More Xdebug

Power Vim Usage: Tips &amp; 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

Related: