Venturing into Vim – Week 4: Premium Video
plusvideos

Venturing into Vim – Week 4: Premium Video

Download Source Files

Some say it’s a decade-old piece of junk; others widely consider it to be the best code editor available. I’m on a quest to find out for myself. So, for four weeks (and four screencasts to track my progress), I will use nothing but Vim.

Along the way, if you choose to join me, I’ll share what I’ve learned, what frustrated me, and everything that falls in between. If you’ve been hoping to venture into Vim territory, there’s no better time to do so! Let’s do it together. Gain access to this screencast series, as well as many others by becoming a Premium member.


Week 4

In this final episode about Vim, we learn about:

  • A plethora of new key commands
  • How to record macros to save time
  • The process of creating bookmarks to always remember where you last were in your project
  • How to move lines of code to new locations as quickly as possible
  • Decoding the completed vimrc file. (Help make it better by forking it on Github!)
  • All of the different mapping commands, and the differences between each
  • IDE-like auto-completion

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://andrewburgess.ca Andrew Burgess

    Great conclusion to a series I’ve really enjoyed; I’ve got two comments:

    - I think the reason . (dot) doesn’t work to repeat the search is because a search is a motion command, and dot is only for repeating editing commands.

    - I prefer not to hard-wrap paragraphs, but long lines can get unwieldy if you have line wrapping turned on. You can just gj and gk to move between graphical lines of text. Then, I’ve seen adding this to your vimrc file:

    nnoremap j gj
    nnoremap k gk
    

    This makes regular j and k move between graphical lines . . . and of course, it doesn’t affect moving between “real” lines. Just thought others who don’t prefer hard wrapping like me might find this helpful.

    Thanks for the great series, Jeffrey!

  • http://twitter.com/garbaczd David Garbacz

    Hey Jeff great close to the series and just wanted to take the time to thank you for making me more familiar with what was such a scary editor.

    Just a quick question, what was that application launcher you brought up MacVim with at the very beginning of the screencast? Looked pretty slick :P

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      It’s called Alfred. :)

      • Nathaniel

        I use Alfred as well, however, mine doesnt look like that. [ex: Vim icon showing on the left as you search for it]

        Whats your secret? :)

  • http://omarello.com omarji

    Hey Jeff, thanks a lot for this series. It was a great for me to finally venture into VIM :)

    One question about Yanking/Copying, I noticed that yanking a line for example does not make it available to other applications, e.g. sometimes I have a sql file from which I want to copy a select statement to run against the db.

    Copying that section using for example ‘yy’ or if I visually select the section and do ‘y’ does not make that text available to be pasted elsewhere. How do you go about doing that?

    Thanks.

  • Joshua

    Kinda sad this was your last one on vim … you have a perfect pace for these…

    Anyway, you kept saying “control” instead of “comma” …

    Other than that though, great series… you re-breathed life back into my drive to switch to vim, and I’m now fully enveloped in it…

  • Joshua

    Hey Jeffery,

    One thing you might want to add to your vimrc… something that drove me absolutely nuts as I stared in vim was that I prefer using “i” predominantly, so adding text to the end of the line was a PIA (i know about “a”, but for some reason I still tend to want to hit “i” instead.)

    set virtualedit=onemore

    that will make your normal mode cursor “act” like there is a single extra character of white space at the end as far as letting your cursor go “one more” char after the end of the line… this is in my list of “must haves” in my vimrc :)

  • http://evansofts.com evanxg

    Please , Can anyone tell me why I am getting this error :

    E510 Can’t create backup file

    When try to save my file . the file is created correctly but any time I modify it, I can’t save it back . I am using vim 7.3 on windows vista. This happen even on the c drive : I mean a file like c:\myfile.txt

  • http://randomnode.blogspot.com/ Ishmael Ahmed

    I’ve been working with vim as my primary text editor for about three years now. When I first got my feet wet I found these site to be invaluable. I still refer to them to this day.

    I love the quote at the begining of this one
    “To me, vi is Zen.
    To use vi is to practice zen.
    Every command is a koan.”
    http://jmcpherson.org/editing.html

    This page is full of useful commands, you may find things you didn’t think where possible from a text editor here.
    http://www.rayninfo.co.uk/vimtips.html

  • Mark Boomaars

    Hi Jeffrey,

    First of all, thanks for yet another great tutorial. I’m really starting to enjoy VIM.
    Found some more handy vimrc settings at http://amix.dk/vim/vimrc.html

    ” Format the statusline
    set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c

    ” Map auto complete of (, “, ‘, [
    inoremap $1 ()i
    inoremap $2 []i
    inoremap $3 {}i
    inoremap $4 {o}O
    inoremap $q ”i
    inoremap $e “”i
    inoremap $t i

    ” Insert date/time
    iab xdate =strftime(“%d/%m/%y %H:%M:%S”)

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Thanks – will take a look!

  • Randie

    I have a suggestion for another vim screencast, if youre interested: Debugging PHP with Vim and XDebug. See http://bit.ly/w9ukF .

  • Nathaniel

    I for the life of me am unable to figure out how to connect to my work server through SFTP.
    I’ve tried searching google, tried using what was provided in these tutorials (Nread), looked for specific plugins too – but to no avail.

    Could anyone help me with this?

    tried:

    :e sftp://username@server.address.com//var/www
    :e sftp://username@server.address.com/var/www
    :Nread sftp://username@server.address.com/var/www

    etc.

    When I do the last one, I get asked for my password… but it says this:::
    :!sftp ‘username@server.address.com/:var/www’ /var/folders/UF/UF84T…. etc etc etc
    Connecting to server.address.com…

    Couldn’t stat remote file: No such file or directory
    File “/home/username/var/www” not found.

    Shell returned 1

    Thanks! Hopefully This will be an easy fix and I can start editing full force in Vim!

  • daily

    Few addons in my .vimrc

    “Set background transparency percentage
    set transparency=20

    “Load the current buffer in Safari – Mac specific.
    abbrev sa :! open -a Safari.app %:p

    “Load the current buffer in Google Chrome – Mac specific
    abbrev ch :! open -a Google\ Chrome.app %:p