Tag Archives: hack

Make selecting with mouse in Vim do so in Visual Mode, Remap arrow keys to act as hjkl

Okay, this is a quick one. In Vim I hated two things:

  1. That selecting text with the mouse did not use visual mode.
  2. That the arrow keys, in visual mode, did not act like hjkl.

Here is what I did to fix #1:

set selectmode=key

Here’s what I did to fix #2:

:map <down> j
:map <up> k
:map <left> h
:map <right> l

Using VIM with NERDTree over FTP/SFTP using ExpanDrive in Windows 7

[iframe width=”100%” height=”380″ src=”http://www.youtube.com/embed/nSeCRTj-KzA?hd=1″]

Note: ExpanDrive did not support regular FTP and was really slow saving/etc.

Now that I am using Vim, I noticed that I was having problems editing files over FTP/SFTP. I couldn’t use NERDTree and my other client, WinSCP, would open a new window (or tab) of gVim when I used an external editor. I wanted to browse an FTP/SFTP natively so that I could use NERDTree and edit as if I was editing locally.

The solution I found was using ExpanDrive, a program that mounts FTP/SFTP locally as a Windows drive. Once I mounted a drive, and chose a file to edit, I could use NERDTree to browse for more or use :vsp and drag a file on that split.

In the video I show it off a little.

Diving into Vim/gVim on Windows; How I customized Vim to edit HTML, CSS, Javascript and PHP w/ ZenCoding, SnipMate, Surround and DelimiMate

Different Flavors of Vim

I have released my gVim configuration as an installable application for windows, check it out: Aubrey’s gVim

It all started with an annoyance with Notepad++, the CTRL+Y (Redo) key was not working and a NetTuts screencast. About two months ago I complained about VIM, yet I still have an itch to use it.  I spent all day yesterday trying to get Vim going, and today I find myself frustrated again. Vim is very customizable, something I really like. But, that customization should ‘just work,’ hell I can’t even get a plugin installed correctly!

I installed a few different forks of Vim (called Cream) and a few vimrc/plugin combinations. But, I have currently reverted to base install gVim/Vim for Windows and started fresh. I will share my finding below.

[adsense metakey=”adsense-1″]
  • This video helped me figure out plugins and how Vim uses folders and files. I used this video as a guide to install (and understand) pathogen and install ZenCoding.
  • I copied the content (extracted on my desktop) of Zencoding.zip to the bundle folder. This should automatically load your plugin since I installed pathogen.
  • Loaded gVim and typed div
  • ZenCoding gave me hell, real hell, because I couldn’t figure out how to expand the abbreviations. But, after a little digging around, I found out <c-y> means type: CTRL+Y then a comma (,). I have a feeling Vim explanations like this are going to cause me not to use Vim. It worked though.
  • I opted to install more plugins, starting with snipMate.
  • I started installing most of the plugins mentioned in this post, or in this post under the ‘Most of the bundles are git submodules facilitating easy updating and configuration’ section. Note, I did not opt to use the Ultimate Vim config, just the plugin suggestions he was giving.
    • The first was the colors. Once I installed it into the bundle folder, I could use (in gVim) the command “:color bluegreen”. For a list of the color schemes, I found this.
      • I had to edit my c:Program FilesVim_vimrc file and added “color bluegreen”.
      • Note: there is a menu, but it does not save the theme you are using as permanent.
    • Then I got to tcomment, and discovered (once I followed the install directions, not putting it in my bundle folder) that it seems to have installed in C:Program FilesVimvimfilesbundleColorSamplerPackautoload, which is kind of weird.
    • I installed HTML AutoCloseTag, but not with the bundle way, that did not work. I followed the install directions (putting it in C:Program FilesVimvimfilesftplugin) and it worked. I typed <body> and it would </body> and put my cursor in the middle.
      • I added au FileType xhtml,xml,php so c:/Program Files/Vim/vimfiles/ftplugin/html_autoclosetag.vim to my _vimrc file to make it work in PHP files also, because often I an doing PHP/HTML coding in a single PHP file.
    • At this point I was starting to feel comfortable with Vim plugins (finally!)
    • I installed delimitMate, which gives you auto completion of ",',[,{,( etc. I used the bundle method for that and downloaded the zip file; I did not use Git.
    • At this point, I was happy with the plugins I had.
  • Now I wanted to start customizing my _vimrc file. I found this post, which gave me a good look at the things I could customize.
    • At this point I was actually editing my _vimrc file using gVim.
    • I noticed CTRL+V worked for paste! Although I did want to use Vim, I did not want to ignore my normal keys. CTRL+C,V,X, etc and the arrows.
    • Here is what I pasted into my _vimrc file:
      set autoindent
      set smartindent
      set tabstop=4
      set shiftwidth=4
      set showmatch
      set guioptions-=T
      set vb t_vb=
      set ruler
      set incsearch
      set virtualedit=all
    • Again, I had to do a :w! to write the file in Vim since it was in C:Program FilesVim.
    • I found this _vimrc file which had a lot of custom things I wanted. I added these to my _vimrc file. I did not overwrite my _vimrc file, just took what I wanted out of it.
      set number
      set guifont=Consolas:h10.5
      "set guioptions+=b "show horizontal scroll bar
      set ttyfast
      set ignorecase
      set list
      set listchars=tab:>-,trail:-
      set showmode
    • Then I noticed all the ~backup files that were getting created, annoying! I added set backupdir=c:temp to my _vimrc file and they were all stored in c:temp. I like the idea of having a backup, just not in the folder I am working in.

And now to see how it goes. I am going to create a separate post for this, but I am going to ZIP up my Vim folder and offer it as a start-off solution. I am probably going to use Vim/gVim for a couple days to edit HTML, CSS, Javascript and PHP and see if it works well first.

Backup and save your feed content using Google Reader & Mozilla Archives

So, today I wanted to go ahead and backup the content from my Google Reader. What I do is subscribe to my own websites, and my Facebook feeds, my Twitter Feeds, etc. Why? Because, say you want to save all your Twitter posts in a convenient file or archive (every single one). What you would have to do is click ‘more posts’ on the bottom of the page over and over until you get all your tweets. The same for your blogs, and Facebook updates, etc. But, because most of these sites use RSS, and Google archives each and every entry (Twitter, for instance, will only let you go so far back), you can load them all up on one page and save them.

This is how I do it (watch video to see what this actually does):

  1. Make sure you install Mozilla Archive.
    It is going to let you save the entire page (with nothing missing) as a file you can load up on your browser, with all the content, faithfully; even offline.
  2. Load up Google Reader and select the feed (or folder, which is what I do all the time) you want to backup.
  3. Start to scroll down to the very last entry.
    Google Reader, by default, loads up more posts as you scroll down until you’ve loaded them all. To cheat, just middle click your mouse and get the scroll lock feature and let it scroll down automatically. Go grab some coffee, talk to a friend, watch a few YouTube movies to pass the time.
  4. Then File > Save Page as Archive.

It’s the best way I have found to backup your online life. I also save entire blogs this way too, so when offline, I can reference the information later (given they don’t use exerpts).

Note that the backup is going to only go as far back to the date you subscribed to the feed. Because of this, anytime I start a site, or start a new service that supports RSS, I subscribe to it and add it to a ‘backup’ folder in Google Reader.

Artweaver, a Photoshop Alternative?

Today I was doing my every-once-in-a-while search for Photoshop alternatives just to see if there was anything out there nower-days. I got the usual results; Gimp, Paint.NET, and some new web-based editors (not what I was looking for). But, I ran across a product that I ended up downloading and giving a shot, it’s called Artweaver. Upon seeing some of the screenshots, I thought it looked surprisingly like Photoshop. So, I gave it a try- and to my amazement (yes, I was actually expecting things to not work right) it is a good canidate for a Photoshop replacement.

I know a few tools that make Photoshop awesome are missing, but I did download the free version (maybe the full version has those tools), and those tools aren’t absolutely imperative to have; many of the things those tools (blending options, drop shadows, etc) can still be done (I show how you can do a drop shadow in the screencast). I was just amazed at hope familiar it felt and how well it worked. I am going to play around with this one a little bit, and hopefully post a follow-up.