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 noremap <leader>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 '<leader>cr'. You will be prompted for a new
18 name if 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')
30 # Get arguments for clang-rename binary.
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)]
47 # FIXME: make it possible to run the tool on unsaved file.
48 p = subprocess.Popen(command,
49 stdout=subprocess.PIPE,
50 stderr=subprocess.PIPE)
51 stdout, stderr = p.communicate()
56 # Reload all buffers in Vim.
57 vim.command("checktime")
60 if __name__ == '__main__':