« back to discussion

If you don't use Vim, you should be!

In light of this discussion, I will use this space to emphasize how if you're not using Vim, you're really missing out.

Note: I heard Vim on windows is not good at all (gvim). You may be better sticking with sublime. Perhaps someone has some insight who uses gvim on how to make the experience a bit smoother. On the off chance you're on a Mac though (MacVim), and have heard people talking about Vim, but never really took a look at it -- it is a magnificent piece of software.

Trying to think of myself going back and using textmate or other single-mode editor is just painful.

If you don't really know what it is, allow me to explain.

Firstly, the learning curve is very heavy but after a good 5-7 days of solid use you will be comfortable enough where you are up to speed at least as fast as your old editor. Give it another month and you should be 4-5x faster, if not more.

Vim basically has multiple "modes", where as a standard editor has one mode. For something like, say, textmate, that single mode is "edit" mode. You move the cursor around with the arrow keys (shudder), or with the mouse (double shudder). If youre good at hotkeys, you may move the cursor around with alt+arrows to skip by word, or command+arrows to go to the beginning/end of line/file.

In Vim, you have multiple modes (I vaguely remember there being 9 or more, but theres 6 main ones you will use): insert mode, normal mode, command mode, visual mode, visual line mode, visual block mode.

insert mode is the equivalent of any other editors text edit mode. This is where you actually write code, delete, etc. Note that this does NOT include movement.

normal mode is used for movement. To get 'into' normal mode from insert mode, you press escape (or, control-C in my case). Technically it's capslock-C because I remapped capslock as a control key. Normal mode is where you move around the file very easily using motion verbs + a direction. for example:

See common actions here for normal mode: http://www.eastcoastefx.com/vim

command mode is used for running commands, its essentially a 'mini terminal'. You can run rails tests from here, run rake tasks, do very complex find replace, and a lot more. To get into command mode you press : from normal mode

visual mode is used for selections. Press v once from normal mode to insert visual mode, then use the movement keys to select a block of code.

visual line mode is entered by pressing shift+v (or V). This selects an entire line at once.

visual block mode is similar to textmate or sublime text's feature where you can hold alt while using the mouse to select some arbitrary 'square' of text, even if its in the middle of the document, and then type on multiple lines at once with multiple cursors.

So, without further ado here are some examples to help make this jumbled mess make sense. Note... these are very simple examples: as stated by tamok in this thread, it can get a lot more complex.

  • Say youre editing HTML. While in normal mode here are a few commands vit will visually select inside the html tag. vat will visually select outside the tag ("visually select around tag" is what vat basically means). You dont need to just visually select something too. dat will delete the outer tag while remaining in normal mode, and cit will delete whats inside a tag and then change to insert mode automatically.
  • Say you want to move a whole block of css text below another one. Instead of selecting it with the mouse like a buster, you can push V%djjp That will enter visual line mode, % will go to a closing brace, d deletes it into a buffer, jj moves down some arbitrary amount, p puts the last thing in the buffer BELOW the cursor (use P to put it above the cursor)
  • to delete all empty lines I do ,del, to format an html document i do gg=G
  • Say I want to wrap a list of text in an unordered list, but the text is prefixed with "- Item" like someone would write it in an email. V3j:s- //g then press return. That will enter visual line mode, go down 3 lines, gsub the selection '- ' with ''. Then press V3kStul>j then enter visual block mode with <c-s-v> (control+shift+v), kk0Stli> to wrap in list item tags using tim Pope's surround plugin. The nice part about vim is you can entirely write your own functions and macros as well, so if you find yourself getting a lot of these lists, you spend 2 minutes writing a function in your .vimrc file and then can do chained functions with one keypress.

Those examples were from my head, and they are in no way the 'best' way, just a few examples to get your feet wet. You can basically think of it as typing your way to movement rather than using the mouse or arrow keys.

about 4 years ago, by pineapple

8 Replies

pineapple

This guy is godlike at vim, as you can probably see from his very short screencast: https://www.destroyallsoftware.com/screencasts

More resources: http://pineapple.io/resources/tagged/vim

pineapple, about 4 years ago

SkinnyGeek1010

+1 ! as a former Sublime Text users, I can concur that once you have Vim setup, and can navigate without thinking, your at the minimum as fast as you were before. You can even still use sublime in Vim mode, thereby using just the minium to get acclimated.

Just think of how easy the wads keys are to use... would you really play CS or WoW with your arrow keys???????? didn't think so! Once it's ingrained you don't even think about it.

The thing with sublime text is that it has so much goodness baked in that it takes a while to convert macvim to something that has all the goodies (albeit uglier) like snippets, fuzzy searching, plugin control, sidebar, tabs, etc..

Once you get in the flow you will (literally) be trying to scroll up/down in your browser with j/k ... They even have an extension for that! lol.

SkinnyGeek1010, about 4 years ago

SkinnyGeek1010
posted by pineapple on Fri, Oct 26 at 01:37PM

This guy is godlike at vim, as you can probably see from his very short screencast

He is ridiculous.... my achilles heel with Vim is my poor typing, specifically my accuracy. I've recently switched careers from graphic design to front-end and we always used the mouse in Photoshop/ InDesign lol. I've been using typingweb.com for typing training daily-ish, which has really helped (from 32-70ish)

Any tips on increasing accuracy? Or is it just practice practice practice?

SkinnyGeek1010, about 4 years ago

pineapple
posted by SkinnyGeek1010 on Fri, Nov 9 at 04:18PM
posted by pineapple on Fri, Oct 26 at 01:37PM

This guy is godlike at vim, as you can probably see from his very short screencast

He is ridiculous.... my achilles heel with Vim is my poor typing, specifically my accuracy. I've recently switched careers from graphic design to front-end and we always used the mouse in Photoshop/ InDesign lol. I've been using typingweb.com for typing training daily-ish, which has really helped (from 32-70ish)

Any tips on increasing accuracy? Or is it just practice practice practice?

I can't think of many tips about accuracy, although these pointers come to mind (either related or slightly related):

  • Don't use typing.io or vim practice websites until your typing speed is at least 90 with just words. Trying to learn all the special number key symbols when you can't type regular words fast will slow you down.
  • Fingers should be very relaxed and nimble, not tensed up.
  • I remap caps lock key to control in OSX preferences. I never use caps lock, and I use control 1000 times a day, it saves my pinky from having to stretch.
  • for vim specifically, really engrain the combos into muscle memory. Common actions like.. when typing css (and I paste in some code for border radius, chances are it will not be indented right). Things like vi{= are just engrained so heavily I type them like regular letters. Usually while I'm coding I make it a game to see how many chained macros I can do without a c-c-c-commbooo breakerrrr
  • Once your speed is good force yourself not to look at the number keys when you want to type # $ &&, { }, etc.

Proof I know somewhat what I'm talking about (took this a few mins ago):

lol typing test

http://www.typingtest.com/

pineapple, about 4 years ago

SkinnyGeek1010
posted by pineapple on Fri, Nov 9 at 04:45PM
posted by SkinnyGeek1010 on Fri, Nov 9 at 04:18PM
posted by pineapple on Fri, Oct 26 at 01:37PM

This guy is godlike at vim, as you can probably see from his very short screencast

He is ridiculous.... my achilles heel with Vim is my poor typing, specifically my accuracy. I've recently switched careers from graphic design to front-end and we always used the mouse in Photoshop/ InDesign lol. I've been using typingweb.com for typing training daily-ish, which has really helped (from 32-70ish)

Any tips on increasing accuracy? Or is it just practice practice practice?

I can't think of many tips about accuracy, although these pointers come to mind (either related or slightly related):

  • Don't use typing.io or vim practice websites until your typing speed is at least 90 with just words. Trying to learn all the special number key symbols when you can't type regular words fast will slow you down.
  • Fingers should be very relaxed and nimble, not tensed up.
  • I remap caps lock key to control in OSX preferences. I never use caps lock, and I use control 1000 times a day, it saves my pinky from having to stretch.
  • for vim specifically, really engrain the combos into muscle memory. Common actions like.. when typing css (and I paste in some code for border radius, chances are it will not be indented right). Things like vi{= are just engrained so heavily I type them like regular letters. Usually while I'm coding I make it a game to see how many chained macros I can do without a c-c-c-commbooo breakerrrr
  • Once your speed is good force yourself not to look at the number keys when you want to type # $ &&, { }, etc.

Proof I know somewhat what I'm talking about (took this a few mins ago):

lol typing test

http://www.typingtest.com/

Cool! I'll keep those tips in mind and work on it!!

I just tried the test on that site and scored a 49 wpm / 6 errors / 43 on my laptop (no das keyboard :/ )... I think I also have to work on the symbols, numbers, that's when my score really tanks into the 30s with < 70% acc.

I'll have to try remapping control to caps!!... I find control extremely awkward on macs, especially on macbooks with the fn key on the outside.

SkinnyGeek1010, about 4 years ago

SkinnyGeek1010

A shortcut guide for people using Textmate that would like to convert over to Vim: http://www.jackkinsella.ie/2011/09/05/textmate-to-vim.html

SkinnyGeek1010, about 4 years ago

pineapple
posted by SkinnyGeek1010 on Sat, Nov 10 at 01:31PM

A shortcut guide for people using Textmate that would like to convert over to Vim: http://www.jackkinsella.ie/2011/09/05/textmate-to-vim.html

Awesomesauce

pineapple, about 4 years ago

pineapple

[deleted]

pineapple, about 4 years ago


Login or to comment.

« back to discussion

Tutorials are any resources you learn from.

Examples: an intro to html5 screencast, a pdf about git, photoshop effects tutorials, meta-programming in ruby, lambda calculus, higher-order fixed-point combinators.

Tools are websites, apps or services used -on- your project (indirectly), to aid the process.

Examples: A color scheme generator, email marketing software, usability heat maps, css3 code generators, a downloadable png compressor.

Assets are downloadable files used -in- your projects, usually as code, textures, or images.

Examples: a jquery sticky menu, photoshop brushes, background textures, mvc frameworks, twitter bootstrap, 960 grid system.