Vim plugin offering syntax highlighting and some mappings for dealing with srt
(subrip) files.
Use <Leader>J
on a subtitle to join the subtitle below it up to it (works like Vim's normal line join
-- see :help J
). This mapping also merges the in and out times in a logical way.
Use <Leader>K
to split a subtitle. Leaves the user in insert
mode to enter new in time for the split subtitle.
If you don't map <Leader>
in your vimrc
, it is set to \
by default.
You can reassign these mappings if you choose. For example, if you wanted to use gJ
and gK
, put the following in your vimrc
:
nmap gJ <Plug>JoinCaption
nmap gK <Plug>SplitCaption
If you want your custom remappings to only work in srt
files, use:
autocmd Filetype srt nmap gJ <Plug>JoinCaption
autocmd Filetype srt nmap gK <Plug>SplitCaption
Biggest issue that I know of is that it won't work for subtitles with multiple lines of text:
1
00:02:17,440 --> 00:02:20,375
Senator, we're making
our final approach into Coruscant.
Other issues:
- The
join
command also doesn't take a count, and none of the mappings work in any mode exceptnormal
. - The dot command doesn't repeat either the join caption or split caption commands, even with vim-repeat installed.
- Ideally the
split
command could change the in and out times in some logical way. - Wondering if there's a smart way to remap the increment and decrement commands:
<C-a>
and<C-x>
.
Please submit an issue or pull request if you have solutions to the above problems, suggestions for improving these mappings, or new mappings that you find helpful when dealing with srt
files!
Syntax highlighting adapted from Josip Deanovic (here's a version on GitHub). Special thanks to Drew Neil's vim-subrip as well.