open file under cursor in window split: Ctrl + W then F
open file under cursor in same window: gf
go back to previous file: Ctrl + ^ OR Ctrl + O

$ cat ~/.vimrc

" NOTE: copy this file to ~/.vimrc

syntax on                   " use default syntax highlighting

set number                  " show line numbers
"set nonumber               " hide line numbers

set tabstop=4               " use 4-space long TAB character
set shiftwidth=4            " use 4-space when text is indented
set expandtab               " insert spaces instead of TAB character

set autoindent              " use current line's indent level to set indent
                            " level of new lines
"set smartindent            " automatically indent while typing, works for
                            " c-like files
set cindent                 " automatically indent while typing, more strict
                            " when it comes to syntax

set colorcolumn=81          " highlight 81st column so that you know where to
                            " wrap the text
"set textwidth=80           " set maxmimum width of text to 80 characters,
                            " longer line is broken after white space to get
                            " this width

set background=dark         " set background dark

set incsearch               " search while entering the search-text
set hlsearch                " highlight the search-text

map <C-]> g<C-]>|           " jump to a tag if there is only one matching tag,
                            " otherwise display a list of matching tags by
                            " pressing Ctrl+]
                            " (| is used to separate map command from comment,
                            " be sure not to include any space before |)
map t :tags <CR>|           " display contents of tag stack by pressing t key
                            " (| is used to separate map command from comment,
                            " be sure not to include any space before |)

fun! ShowFuncName()         " show function name based on current position of
                            " cursor by pressing f key or by moving cursor
    let line = getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bcWn'))
    if line != ""
        echohl ModeMsg
        echo "FILE: "
        echohl None
        echon @%

        echohl ModeMsg
        if stridx(line, "(") == -1
            echon "  SYMB: "
            echon "  FUNC: "
        echohl None
        echon line
        echon ""
    unlet line
map f :call ShowFuncName() <CR>
autocmd CursorMoved * :call ShowFuncName()

No comments: