remi-vimilicious 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vimilicious.rb +38 -2
- data/vimilicious.gemspec +1 -1
- metadata +1 -1
data/lib/vimilicious.rb
CHANGED
@@ -77,20 +77,54 @@ def current_line
|
|
77
77
|
current_buffer.line
|
78
78
|
end
|
79
79
|
|
80
|
+
# set the text of the currently selected line
|
81
|
+
#
|
82
|
+
# we're not using the more conventional current_line= because
|
83
|
+
# that simply creates a local variable named current_line
|
84
|
+
#
|
85
|
+
# :ruby set_current_line 'hi there'
|
86
|
+
def set_current_line text
|
87
|
+
current_buffer[ current_buffer.line_number ] = text.to_s
|
88
|
+
end
|
89
|
+
|
80
90
|
# deletes the current buffer (closes the file)
|
81
91
|
#
|
82
92
|
# :ruby clear
|
83
93
|
def clear
|
94
|
+
cmd 'bd'
|
95
|
+
end
|
96
|
+
|
97
|
+
# forcefully deletes the current buffer (closes the file) (unsaved changes will be lost!)
|
98
|
+
#
|
99
|
+
# :ruby clear!
|
100
|
+
def clear!
|
84
101
|
cmd 'bd!'
|
85
102
|
end
|
86
103
|
|
104
|
+
# append text to the end of the current_buffer
|
105
|
+
#
|
106
|
+
# :ruby append 'hello there'
|
107
|
+
def append text
|
108
|
+
current_buffer.append current_buffer.length, text
|
109
|
+
end
|
110
|
+
|
111
|
+
# prompts user for input
|
112
|
+
#
|
113
|
+
# :ruby prompt('username')
|
114
|
+
def prompt name = 'input', format = lambda { |name| "#{name}: " }
|
115
|
+
input = vim_eval("inputdialog('#{ format.call(name) }')")
|
116
|
+
puts '' # clear statusline thinger
|
117
|
+
input
|
118
|
+
end
|
119
|
+
|
87
120
|
# create a vim user command that calls a ruby method or block
|
88
121
|
#
|
89
122
|
# :ruby create_command :test # creates a :Test command that calls a 'test' method
|
90
123
|
# :ruby create_command 'test', :hi # creates a :Test command that calls a 'hi' method
|
91
124
|
# :ruby create_command(:test){ puts 'hi' } # creates a :Test command that calls the block passed in
|
92
125
|
#
|
93
|
-
#
|
126
|
+
# WARNING ... as of now, the args passed to these commands get turned into one big string which
|
127
|
+
# is passed along to the function and method. i haven't figured out howto fix this yet :(
|
94
128
|
def create_command name, method = nil, &block
|
95
129
|
command_name = name.to_s.capitalize
|
96
130
|
method_name = (method.nil?) ? name.to_s : method.to_s
|
@@ -106,7 +140,7 @@ def create_command name, method = nil, &block
|
|
106
140
|
end
|
107
141
|
|
108
142
|
# create a vim command that calls the vim function
|
109
|
-
cmd %{command! -nargs=* #{ command_name } call #{ function_name }(<
|
143
|
+
cmd %{command! -nargs=* #{ command_name } call #{ function_name }(<args>)}
|
110
144
|
end
|
111
145
|
|
112
146
|
# get the word under the cursor
|
@@ -123,3 +157,5 @@ def current_word filter=/[,'`\.:\(\)\[\]\}\{]/, replace_with=''
|
|
123
157
|
end
|
124
158
|
|
125
159
|
### COMMANDS ###
|
160
|
+
|
161
|
+
create_command('InspectArgs'){ |*args| puts "passed: #{args.inspect}" }
|
data/vimilicious.gemspec
CHANGED