2 Minimal clang-rename integration with Vim.
4 Before installing make sure one of the following is satisfied:
6 * clang-rename is in your PATH
7 * `g:clang_rename_path` in ~/.vimrc points to valid clang-rename executable
8 * `binary` in clang-rename.py points to valid to clang-rename executable
10 To install, simply put this into your ~/.vimrc
12 map ,cr :pyf <path-to>/clang-rename.py<cr>
14 IMPORTANT NOTE: Before running the tool, make sure you saved the file.
16 All you have to do now is to place a cursor on a variable/function/class which
17 you would like to rename and press ',cr'. You will be prompted for a new name if
18 the cursor points to a valid symbol.
26 binary =
'clang-rename'
27 if vim.eval(
'exists("g:clang_rename_path")') ==
"1":
28 binary = vim.eval(
'g:clang_rename_path')
31 offset = int(vim.eval(
'line2byte(line("."))+col(".")')) - 2
33 print >> sys.stderr,
'''Couldn\'t determine cursor position.
34 Is your file empty?'''
36 filename = vim.current.buffer.name
38 new_name_request_message =
'type new name:'
39 new_name = vim.eval(
"input('{}\n')".format(new_name_request_message))
45 '-offset', str(offset),
46 '-new-name', str(new_name)]
48 p = subprocess.Popen(command,
49 stdout=subprocess.PIPE,
50 stderr=subprocess.PIPE)
51 stdout, stderr = p.communicate()
57 vim.command(
"bufdo edit")
60 if __name__ ==
'__main__':