Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open next file in VIM

Tags:

vim

buffer

I have the following files in directory:

" ============================================================================
" Netrw Directory Listing                                        (netrw v149) 
"   /home/.../content
"   Sorted by      name
"   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$...
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:exec
" ============================================================================
../
./
.swo
1
10-1
10-2
10-3
10-4
10-5
10-6
2
3
4
5
6
7
8-1
8-2
8-3
9-1
9-2
9-3
9-4
9-5

Having 10-2 buffer opened, how can I open for editing the next file (10-3)?

What about going back?

Right now I do :Ex and then go to the next file.

like image 329
Ionică Bizău Avatar asked Jan 18 '26 14:01

Ionică Bizău


2 Answers

  • My EditSimilar plugin provides (among others) :EditNext and :EditPlus commands.
  • unimpaired.vim - Pairs of handy bracket mappings includes a pair of [f / ]f mappings to go to the previous / next file
like image 97
Ingo Karkat Avatar answered Jan 21 '26 08:01

Ingo Karkat


You can load all the files:

:args *

Then use :bn and :bp to switch.

EDIT: Okay, macro time... use these mappings:

nmap <leader>[ :Ex<CR>k<CR>
nmap <leader>] :Ex<CR>j<CR>

Note that this kind of depends on <CR> mapping from netrw, so you can't use nnoremap.

like image 23
Amadan Avatar answered Jan 21 '26 08:01

Amadan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!