robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Phạm Bình Andocs: misc #37357d96a88252e

master
6.0 KiB194 linesraw
1*if_ruby.txt*          Nvim
2
3
4		  VIM REFERENCE MANUAL	  by Shugo Maeda
5
6The Ruby Interface to Vim				*if_ruby* *ruby* *Ruby*
7
8See |provider-ruby| for more information.
9
10			*E266* *E267* *E268* *E269* *E270* *E271* *E272* *E273*
11
12The home page for ruby is https://www.ruby-lang.org/.  You can find links for
13downloading Ruby there.
14
15                                      Type |gO| to see the table of contents.
16
17==============================================================================
181. Commands						*ruby-commands*
19
20							*:ruby* *:rub*
21:rub[y] {cmd}		Execute Ruby command {cmd}.  A command to try it out: >
22				:ruby print "Hello"
23
24:rub[y] << [trim] [{endmarker}]
25{script}
26{endmarker}
27			Execute Ruby script {script}.
28
29			If [endmarker] is omitted, it defaults to a dot '.'
30			like for the |:append| and |:insert| commands.  Refer
31			to |:let-heredoc| for more information.
32
33
34			This form of the |:ruby| command is mainly useful for
35			including ruby code in vim scripts.
36
37Example Vim script: >
38
39	function! RedGem()
40	ruby << EOF
41	class Garnet
42		def initialize(s)
43			@buffer = VIM::Buffer.current
44			vimputs(s)
45		end
46		def vimputs(s)
47			@buffer.append(@buffer.count,s)
48		end
49	end
50	gem = Garnet.new("pretty")
51	EOF
52	endfunction
53<
54To see what version of Ruby you have: >
55	:ruby print RUBY_VERSION
56<
57
58						*:rubydo* *:rubyd* *E265*
59:[range]rubyd[o] {cmd}	Evaluate Ruby command {cmd} for each line in the
60			[range], with $_ being set to the text of each line in
61			turn, without a trailing <EOL>.  Setting $_ will
62			change the text, but note that it is not possible to
63			add or delete lines using this command.
64			The default for [range] is the whole file: "1,$".
65
66							*:rubyfile* *:rubyf*
67:rubyf[ile] {file}	Execute the Ruby script in {file}.  This is the same
68			as `:ruby load 'file'`, but allows file name completion.
69
70Executing Ruby commands is not possible in the |sandbox|.
71
72==============================================================================
732. The VIM module					*ruby-vim*
74
75Ruby code gets all of its access to vim via the "VIM" module.
76
77Overview >
78	print "Hello"			      # displays a message
79	VIM.command(cmd)		      # execute an Ex command
80	num = VIM::Window.count		      # gets the number of windows
81	w = VIM::Window[n]		      # gets window "n"
82	cw = VIM::Window.current	      # gets the current window
83	num = VIM::Buffer.count		      # gets the number of buffers
84	b = VIM::Buffer[n]		      # gets buffer "n"
85	cb = VIM::Buffer.current	      # gets the current buffer
86	w.height = lines		      # sets the window height
87	w.cursor = [row, col]		      # sets the window cursor position
88	pos = w.cursor			      # gets an array [row, col]
89	name = b.name			      # gets the buffer file name
90	line = b[n]			      # gets a line from the buffer
91	num = b.count			      # gets the number of lines
92	b[n] = str			      # sets a line in the buffer
93	b.delete(n)			      # deletes a line
94	b.append(n, str)		      # appends a line after n
95	line = VIM::Buffer.current.line       # gets the current line
96	num = VIM::Buffer.current.line_number # gets the current line number
97	VIM::Buffer.current.line = "test"     # sets the current line number
98<
99
100Module Functions:
101
102							*ruby-message*
103VIM::message({msg})
104	Displays the message {msg}.
105
106							*ruby-set_option*
107VIM::set_option({arg})
108	Sets a vim option.  {arg} can be any argument that the ":set" command
109	accepts.  Note that this means that no spaces are allowed in the
110	argument!  See |:set|.
111
112							*ruby-command*
113VIM::command({cmd})
114	Executes Ex command {cmd}.
115
116							*ruby-evaluate*
117VIM::evaluate({expr})
118	Evaluates {expr} using the vim internal expression evaluator (see
119	|expression|).  Returns the expression result as a string.
120	A |List| is turned into a string by joining the items and inserting
121	line breaks.
122
123==============================================================================
1243. VIM::Buffer objects					*ruby-buffer*
125
126VIM::Buffer objects represent vim buffers.
127
128Class Methods:
129
130current		Returns the current buffer object.
131count		Returns the number of buffers.
132self[{n}]	Returns the buffer object for the number {n}.  The first
133		number is 0.
134
135Methods:
136
137name		Returns the full name of the buffer.
138number		Returns the number of the buffer.
139count		Returns the number of lines.
140length		Returns the number of lines.
141self[{n}]	Returns a line from the buffer.  {n} is the line number.
142self[{n}] = {str}
143		Sets a line in the buffer.  {n} is the line number.
144delete({n})	Deletes a line from the buffer.  {n} is the line number.
145append({n}, {str})
146		Appends a line after the line {n}.
147line		Returns the current line of the buffer if the buffer is
148		active.
149line = {str}    Sets the current line of the buffer if the buffer is active.
150line_number     Returns the number of the current line if the buffer is
151		active.
152
153==============================================================================
1544. VIM::Window objects					*ruby-window*
155
156VIM::Window objects represent vim windows.
157
158Class Methods:
159
160current		Returns the current window object.
161count		Returns the number of windows.
162self[{n}]	Returns the window object for the number {n}.  The first
163		number is 0.
164
165Methods:
166
167buffer		Returns the buffer displayed in the window.
168height		Returns the height of the window.
169height = {n}	Sets the window height to {n}.
170width		Returns the width of the window.
171width = {n}	Sets the window width to {n}.
172cursor		Returns a [row, col] array for the cursor position.
173		First line number is 1 and first column number is 0.
174cursor = [{row}, {col}]
175		Sets the cursor position to {row} and {col}.
176
177==============================================================================
1785. Global variables					*ruby-globals*
179
180There are two global variables.
181
182$curwin		The current window object.
183$curbuf		The current buffer object.
184
185==============================================================================
1866. rubyeval() Vim function				*ruby-rubyeval*
187
188To facilitate bi-directional interface, you can use |rubyeval()| function to
189evaluate Ruby expressions and pass their values to Vim script.
190
191The Ruby value "true", "false" and "nil" are converted to v:true, v:false and
192v:null, respectively.
193
194 vim:tw=78:ts=8:noet:ft=help:norl: