![](https://secure.gravatar.com/avatar/4a68af71fe5327c72564458ef9d00c6b.jpg?s=120&d=mm&r=g)
Which text editor can do that, find too long sentences? Huseyin Am 15.02.2013 13:55, schrieb ntg-context-request@ntg.nl:
This sounds more like a job for the text editor. Many text editors already know what a sentence is. That means it's as easy as looping over all sentences and counting the characters/bytes and performing some action (e.g. placing the cursor or injecting a ConTeXt macro).
Marco
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2013–02–15 "H. Özoguz" wrote:
Which text editor can do that, find too long sentences?
None, since no editor knows by default what “too long” is. But a few editors (at least vim and I assume emacs as well) have an idea of what a sentence is. Both are scriptable, which means you can tell them what you consider “too long”. If you use a different editor read the manual or ask your favourite search engine. In vim pressing “vis” (visualise inner sentence) marks the current sentence, then pressing “g<Ctrl-g>” yields: Selected 2 of 4 lines; 14 of 50 words; 82 of 296 bytes That means current sentence is 82 bytes long. The rest is up to you. Pick a language you like, vim uses its own scripting language but also has bindings for python, perl, lua, etc. Pseudo-code: go to begin of file start: get byte length of sentence if length > max_length % do something fi move on to the next sentence goto start Or just define a regular expression for a sentence (google is your friend) and use a scripting language directly if your editor is not scriptable. Marco
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2013–02–15 Marco Patzer wrote:
In vim pressing “vis” (visualise inner sentence) marks the current sentence, then pressing “g<Ctrl-g>” yields:
Selected 2 of 4 lines; 14 of 50 words; 82 of 296 bytes
That means current sentence is 82 bytes long. The rest is up to you. Pick a language you like, vim uses its own scripting language but also has bindings for python, perl, lua, etc. Pseudo-code:
go to begin of file start: get byte length of sentence if length > max_length % do something fi move on to the next sentence goto start
Here's a quick and naïve vim function which moves the cursor to the last sentence containing more than 250 bytes when you hit F9. function! GoToLastTooLongSentence() let maxSentenceLength = 250 while line('.') != 1 normal ( | yis let num = strlen(@") if num >= maxSentenceLength normal vis " just for demonstration, remove this break endif endwhile endfunction noremap <F9> :call GoToLastTooLongSentence()<cr> Marco
participants (2)
-
"H. Özoguz"
-
Marco Patzer