About: Jump to a random line   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

The bash shell provides the RANDOM environment variable that gives a random integer from 0 to 32767 inclusive, on many Linux systems. Since 0G jumps to the last line, this variable provides line numbers effectively from 1 to 32768 inclusive, and if the number of lines in the buffer is 32768 or less, the following can be used to define a command such that :RandomLine will jump to a random line in the buffer: :command! RandomLine execute 'normal! '.(system('/bin/bash -c "echo -n $RANDOM"') % line('$')).'G'

AttributesValues
rdfs:label
  • Jump to a random line
rdfs:comment
  • The bash shell provides the RANDOM environment variable that gives a random integer from 0 to 32767 inclusive, on many Linux systems. Since 0G jumps to the last line, this variable provides line numbers effectively from 1 to 32768 inclusive, and if the number of lines in the buffer is 32768 or less, the following can be used to define a command such that :RandomLine will jump to a random line in the buffer: :command! RandomLine execute 'normal! '.(system('/bin/bash -c "echo -n $RANDOM"') % line('$')).'G'
Version
  • 7(xsd:integer)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 1673(xsd:integer)
Author
  • Udslk
Subpage
  • /201108
Complexity
  • basic
Created
  • 2011-08-31(xsd:date)
ID
  • 1674(xsd:integer)
NEXT
  • 1675(xsd:integer)
abstract
  • The bash shell provides the RANDOM environment variable that gives a random integer from 0 to 32767 inclusive, on many Linux systems. Since 0G jumps to the last line, this variable provides line numbers effectively from 1 to 32768 inclusive, and if the number of lines in the buffer is 32768 or less, the following can be used to define a command such that :RandomLine will jump to a random line in the buffer: :command! RandomLine execute 'normal! '.(system('/bin/bash -c "echo -n $RANDOM"') % line('$')).'G'
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software