Tag: trick

Project-Specific Vim Configuration

Usually, we have our own vim configuration in the file ~/.vimrc
What if we want one for our project?
For example, we are working on certain project which needs to read in a tags file.
Well, here is a possible solution.

You put a line at then end of your ~/.vimrc file

source ./.project.vim

Then for each project, put your project-specific stuff in a the file “.project.vim”.

If you don’t want the error message says vim cannot find the file “.project.vim”,
wrap the line above with an if statement:

if filereadable("./.project.vim")
    source ./.project.vim


tail -n

Quite useful trick, when you want to get rid of the first certain lines of the output/file.

$tail -n +2

tail prints out the result starts from the 2nd line.

When you use the “find” command to generate a file list under certain folder, this is quite easy to eliminate the folder path at the beginning of the output.

Learned this from SO How can I remove the first line of a text file using bash/sed script?




    DemoStruct demos[4] = {
        {.val = 1, .point = &a},
        {.val = 2},        
        {.point = &b},
        {.val = 3, .point = &c},

对于结构复杂一点的struct,这么写是不是挺好看的 :]