0

I like to use Vim (and the shell) to edit my files. When I generate a migration, I often find it cumbersome to try to complete through a datetime like 20121209200054.

How can I edit the last file in db/migrate (the one just generated) easily?

Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75

2 Answers2

1

You could simply ls the directory and feed that into the vim command:

vim db/migrate/$(ls db/migrate/ | tail -n 1)

You can then make a Bash alias out of that (in your ~/.bashrc or ~/.bash_aliases)

alias vim-last-migration='vim db/migrate/$(ls db/migrate/ | tail -n 1)'

Or is there a better way?

Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75
0

with vim-rails you can just do :Emigration

Les Nightingill
  • 5,662
  • 1
  • 29
  • 32