Saturday, August 27, 2016

Three Minutes Daily Vim Tip: Open Specific Location

Say you are compiling your code, and the compiler warns you with error in line 77 of your main.c file. You want to go to this specific line of this file. You could do this in two steps, i.e., open up the file and go to the line.

$ vim main.c
:77

Well, there is a a bit easier way to do this in one command:
$ vim +77 main.c

This command will open up main.c file at line 77.

Next, say you want to open up the file and go to your function main(). To do this, you would normally do
$ vim main.c
/main(

Again, there is a single command to do this:
$ vim +/main\( main.c

Note the presence of backslash \, which will tell the shell to input literal parenthesis ( character.

Happy Vimming!

No comments:

Post a Comment