vim - how to make netrw list .h and .c files together as pairs? -
can netrw :e display .h , .c files pairs?
for example:
file1.h file1.c file2.h file2.c file3.h file3.c currently netrw :e list files in sequence:
file1.h file2.h file3.h file1.c file2.c file3.c
from understand :h netrw-sort-sequence, g:netrw_sort_sequence setting default prioritizes .h files on .c files.
you can add following vimrc file change default behavior:
let g:netrew_sort_sequence = '[\/]$,\<core\%(\.\d\+\)\=,\.[a-np-z]$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$' note: lack of .h , .c extensions.
aside switching files
there many (nicer in opinion) ways switching between files apart using file explorer netrw aka :explore. name few:
- fuzzy finder e.g. ctrlp
- projectionist structured projects
- using
:find,'path' - using
%represent current file. see:h :_% - using
<tab>completion (as<c-d>):e(also accepts globs)
for c projects have nice .c <-> .h switching options.
plugins
switching plugins fswitch c/c++ .h/.c switcher. please see :h fswitch-setup more information.
there few other plugins similar things: altr , a.vim name few.
vanilla vim
if plugins not thing can use % tricks. e.g. :sp %<.h
or maybe quick , dirty mapping:
nnoremap <f4> :e %:p:s,.h$,.x123x,:s,.c$,.h,:s,.x123x$,.c,<cr> for more information see following vim wiki page: easily switch between source , header file
Comments
Post a Comment