vim: Search & replace -
vim: Search & replace -
i searching easy way search , replace things in vim "workaround" refactoring.
on other stackoverflow-question found snippet of code:
nnoremap gr gd:%s/<c-r>///gc<left><left><left> i thought gd selects current word under cursor in whole document , %s search , replaces matches after typed replace pattern. gc stands globally confirmation?!
however: not work expected. illustration in python class of mine can easy rename occurencies of self in whole file not work on method identifieres or field identifieres length of one.
def __init__(self): self.test = [] self.a = [] ... so self changed using snippet, doing gr on field a not work.
how can work easy search , replace on 1 file?
any tips on intelligent refactoring appreciated. after hours of searching found plugins , workarounds work c files, need @ to the lowest degree java, python , php compatibility.
thanks every reply :)
update: found out works if initial selected pattern on origin of line. if pattern somewhere in middle of line not work...any ideas?
gd "go global declaration", see :help gd.
the mapping:
jumps 1st occurrence of word under cursor in buffer gd,
populates command-line %s/, meaning "substitute in whole buffer",
followed search pattern used gd, inserted <c-r>/,
an empty pair of slashes, //, replacement,
the flags gc mean "do magic on every match on line , inquire confirmation",
and goes <left><left><left> place cursor between //, ready type replacement.
that mapping claims do, here, no matter how long word under cursor is.
vim not ide, don't expect "intelligent".
search vim replace refactoring
Comments
Post a Comment