In addition to my last post which was how to show line numbers in Vim I soon after wanted to find a way to jump to the line number I knew I needed to edit.
Using a combination of grep -n “blah blah” file.txt which will return the string if found and the line numbers that it was found on.
Armed with the line number from grep I soon found a way to jump to line number in vim.
Simply do the following.
:956 + enter (obviously replacing 956 with whatever your line number is)
And that’s all there is to it.
You can jump to the beginning and end of files as well by simply Hitting G.
Why it’s taken me quite this long to decide I actually really want to just see line numbers in VIM on one or all of my live servers I have no idea.
I think it’s mainly because out of lazyness when an apps in development I have got into the habit of using “mate” (Textmate’s CLI) instead.
Needless to say to enable line numbers in vim, for use with any installation of vim be it server or local machine is really easy.
Open up a terminal (connect to your server if your doing it to remote) once ready type:-
Hit “i” for insert mode and enter “set number”.
Now esc – :wq to save and quit and that’s it.
Line numbers will now show in your next document opened by vim.
Incredibly useful function that i’ve been using alot today to help move clients sites into a new server setup quickly using rysnc.
rsync is a software application and network protocol for Unix-like and Windows systems that synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate (thanks Wikipedia).
rsync -avz -e ssh username@yourotherserver:/pathto/domain/html/wp-content/plugins .
In this case I rsync the plugins folder into the current working directory (make sure if your copying and pasting this command to CD into the right folder first before running).
Trust me this will save you time!