summaryrefslogtreecommitdiff
path: root/tools/clang-rename/clang-rename.py
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /tools/clang-rename/clang-rename.py
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'tools/clang-rename/clang-rename.py')
-rw-r--r--tools/clang-rename/clang-rename.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/clang-rename/clang-rename.py b/tools/clang-rename/clang-rename.py
index 3cc6644ff8f0a..3381c5267f1c0 100644
--- a/tools/clang-rename/clang-rename.py
+++ b/tools/clang-rename/clang-rename.py
@@ -7,10 +7,14 @@ Before installing make sure one of the following is satisfied:
* `g:clang_rename_path` in ~/.vimrc points to valid clang-rename executable
* `binary` in clang-rename.py points to valid to clang-rename executable
-To install, simply put this into your ~/.vimrc
+To install, simply put this into your ~/.vimrc for python2 support
noremap <leader>cr :pyf <path-to>/clang-rename.py<cr>
+For python3 use the following command (note the change from :pyf to :py3f)
+
+ noremap <leader>cr :py3f <path-to>/clang-rename.py<cr>
+
IMPORTANT NOTE: Before running the tool, make sure you saved the file.
All you have to do now is to place a cursor on a variable/function/class which
@@ -18,6 +22,7 @@ you would like to rename and press '<leader>cr'. You will be prompted for a new
name if the cursor points to a valid symbol.
'''
+from __future__ import absolute_import, division, print_function
import vim
import subprocess
import sys
@@ -30,8 +35,8 @@ def main():
# Get arguments for clang-rename binary.
offset = int(vim.eval('line2byte(line("."))+col(".")')) - 2
if offset < 0:
- print >> sys.stderr, '''Couldn\'t determine cursor position.
- Is your file empty?'''
+ print('Couldn\'t determine cursor position. Is your file empty?',
+ file=sys.stderr)
return
filename = vim.current.buffer.name
@@ -51,7 +56,7 @@ def main():
stdout, stderr = p.communicate()
if stderr:
- print stderr
+ print(stderr)
# Reload all buffers in Vim.
vim.command("checktime")