-
Editing bash command in vim
You can open the current command you are typing for editing in your default text editor by pressing
Ctrl + x + e
. It will be executed after you write and quit the file. This is perfect for editing long/multi-line commands where typos are likely to occur. Consider something like this:for run in {1..10} do echo "Print me ten times" done
Editing this in vim is much more satisfying, isn’t it?
You can also open the last executed command for editing if you execute the
fc
command. You can also edit the last command starting with a certain pattern usingfc [pattern]
(you can skip the editor and execute the output offc
by adding the-s
option, and a useful tip is to havealias r="fc -s"
, which would allow you to execute the last command starting with “cc” by runningr cc
).P.S: In order for this trick to open
vim
and not any other editor, make sure you have the lineEDITOR=vim
in your~/.bashrc
. Obviously this works with any text editor. -
Vim, pathogen and git submodules
This is a step by step tutorial on how to organize your vim config files using git, pathogen, and git submodules. This tutorial assumes that you are familiar with git basics, but you don’t really need to understand every step in order to follow it. For simplicity, only
.vim
directory is a repository in this example. You may want to have all your dotfiles under version control and use a script to symlink files to the home directory. For example see https://github.com/ruslanosipov/dotfiles.Setting up
Let’s assume your
.vim
directory is a mess and is not under revision control. Let’s initialize a repository.cd ~/.vim git init git remote add origin git@github.com:user/project.git
Now let’s create
.vim/bundle
directory and clonepathogen
plugin as a submodule.mkdir bundle cd bundle git submodule add git@github.cfm:tpope/vim-pathogen.git bundle/vim-pathogen
Pre-pend the following code to your
~/.vimrc
to load pathogen from non-default directory:runtime bundle/vim-pathogen/autoload/pathogen.vim execute pathogen#infect()
Let’s add some more plugins as git submodules, for example:
git submodule add git@github.com:Lokaltog/vim-easymotion.git bundle/vim-easymotion
Now we can add and commit everything and push it to a repository.
git add . git commit -m "Use pathogen to keep track of vim plugins" git push origin master
Deploying
Assuming that your repository is located at
git@github.com:user/project.git
:cd ~ git clone git@github.com:user/project.git .vim
And you are done, all plugins are downloaded from their repositories now.
Maintaining
Git submodules keep track of specific commits and are not being automatically updated when target repositories have new commits. In order to update plugins you have:
cd ~/.vim git submodule foreach git pull git add bundle git commit -m "Updated all the plugins in a bundle" git push origin master
You probably want to make sure that new versions of plugins are compatible with each other before committing, however.
-
IRSSI - ignore all from everyone
If you visit noisy IRC channels like the programming ones on freenode, you probably want to ignore all the annoying status messages.
To permanently ignore joins, parts, quits, and nickname changes from every channel in IRSSI:
/ignore * joins parts quits nicks /save
I keep forgetting the exact syntax, so maybe clipping the snippet in a blog post will keep it in my memory.
-
Vim movement cheatsheet
I had this lying around for a while now. This is great vim movement commands cheat sheet made by Ted Naleid (link to the original post). It does an amazing job aiding in the memorization of essential vim movement shortcuts.
-
Rename commit author in git
In some extremely rare cases you end up pushing data to the repo with the wrong credentials. If you are the only author and you’re as picky as I am, it can be corrected easily:
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Stan Smith'; GIT_AUTHOR_EMAIL='stansmith@cia.gov'; GIT_COMMITTER_NAME='Stan Smith'; GIT_COMMITTER_EMAIL='stansmith@cia.gov';" HEAD git push --force
In the case of there being multiple people working on a project, you may want to use the following gist posted by anonymous: https://gist.github.com/anonymous/2523336/ (again, followed by
git push --force
).