Comments (13)
Yea that sounds like a pretty useful feature. It would avoid having to open each buffer manually for search and replaces. I'll give it some thought.
from vim-ags.
Just a quick thought on this, I use very similar workflow.
I first use some search tool (Ack or Ggrep) that populates the location list and then I use this plugin https://github.com/Peeja/vim-cdo to run replace command on those like
Cdo s/something/somethingelse.
So it would be really cool if there was some way of populating the location buffer or quickfix buffer with the results of ags.
from vim-ags.
@mohitleo9, @renajohn actually, I'm working on an editable version of the search results. It's still a work in progress but I could use some feedback. It's on the feature-edit branch. In the search results window pressing E will make the results editable, after which lines can be edited and on write all files changed are updated. No lines can be added or removed though.
from vim-ags.
Cool! I'll have a look during the day (Geneva time). Any reason you want to have an edit mode with E
as opposed to using the buffer save as the trigger? It looks like an extra step to me.
Another side comment, I got tricked yesterday with EnMasse. I've bulk edited several files but some of them had changed between the moment I did my Ag and the moment I've saved my modifications with EnMasse. The result was so bad I had to revert some of my files. Do you think it would be possible to refuse the edition if the any file has changed between the moment the search was done and the moment the edit is saved?
from vim-ags.
Had a look at your branch. It's awesome, well done!
Comments:
- How can I go out of edit mode?
- It feels disturbing to be able to edit line numbers. I would remove them in edit mode
- It would be nice to be able to add lines/remove lines, but I can leave without it
Bugs
- Deleting file number will delete as many characters in the file than deleted numbers. For instance, if I have:
123 if (foo) {
and I delete 12
then save, the if
in my target file will be deleted. I will only have:
(foo) {
from vim-ags.
Thanks for the quick feedback. Here are some answers to your comments
- Once in edit mode the only way to exit is either to re-run the search (it will open in the same window) or to close the results buffer if done (I've added an AgsQuit command for that as well).
- The line numbers, as well as the file paths are not meant to be edited, they are there just as visual cues. The width of the line numbers is used to detect where the actual file line starts. So, deleting any characters from there will result in deleting characters from the actual file line. Come to think of it, this could interfere with the search and replace if replacing numbers and they happen to match any values in the line number. I think I'll add a setting to hide/show those and maybe I'll hide them by default.
- Adding/deleting lines make things more complicated and I'm not sure there's a good use case for it. I may reconsider this if there's enough demand for it.
- Regarding aborting the edits if a file has changed, I think I can put something in place. Maybe, I'll have a setting to enable/disable this behavior. I will only be able to detect if any of the lines that appear in the search results has changed. By the way you can undo any edits just by undoing them in the search window and then re-saving.
from vim-ags.
Once in edit mode the only way to exit is either to re-run the search (it will open in the same window) or to close the results buffer if done (I've added an AgsQuit command for that as well).
Do you think you could map q
to re-run the search when in edit mode? The idea would be to hit E
and modify a few occurrences of the search term then hit q
to quite edit mode and have an updated version of the search.
The line numbers, as well as the file paths are not meant to be edited, they are there just as visual cues. The width of the line numbers is used to detect where the actual file line starts. So, deleting any characters from there will result in deleting characters from the actual file line. Come to think of it, this could interfere with the search and replace if replacing numbers and they happen to match any values in the line number. I think I'll add a setting to hide/show those and maybe I'll hide them by default.
Adding/deleting lines make things more complicated and I'm not sure there's a good use case for it. I may reconsider this if there's enough demand for it.
Having a setting and hiding line number by default, is most likely the best solution. I would not even bother to have a setting to activate line number in edit mode, but it's just my opinion.
Regarding aborting the edits if a file has changed, I think I can put something in place. Maybe, I'll have a setting to enable/disable this behavior. I will only be able to detect if any of the lines that appear in the search results has changed. By the way you can undo any edits just by undoing them in the search window and then re-saving.
Sounds good. Thank you for all your work! I'm already using your branch daily. It's super useful.
from vim-ags.
Just seen that line number option is already in. Wow!
from vim-ags.
Do you think you could map
q
to re-run the search when in edit mode? The idea would be to hitE
and modify a few occurrences of the search term then hitq
to quite edit mode and have an updated version of the search.
I don't really want to add any maps in edit mode. Some people may want the original q
functionality. But you could add some maps if you wish.
For example I have these two maps in my vimrc
nnoremap <LEADER>a :Ags<SPACE>
nnoremap <LEADER><LEADER>a :AgsQuit<CR>
And so I can easily re-run the search or quit the search window.
from vim-ags.
Ok, makes sense. I do love macro so I can understand you would use them for a bulk replace.
I'll follow your advice and add mappings in my nvimrc (I'm using NeoVim since this week. It rocks!). I already have that one in my nvimrc:
nnoremap <LEADER>a :Ags<SPACE>
I'll add the other one, it looks really handy.
from vim-ags.
You can close this issue if you want. Thank you so much for this new feature!
from vim-ags.
You're welcome, and thanks for helping out with this feature. I'll close this once I merge the feature branch into master.
from vim-ags.
Fixed
from vim-ags.
Related Issues (20)
- What's the difference between this plugin and CtrlSF HOT 1
- How can I return back to SearchView from Edit Mode HOT 1
- Why can't I add lines to the edit view? HOT 1
- Lightline integration on readme HOT 2
- Problems getting search to follow symlinks HOT 4
- replace breaks format
- [Neovim] add async support? HOT 5
- reuse last window behavior HOT 4
- default mapping for next/prev result HOT 2
- Searching from git root HOT 10
- Regression for searches with spaces? HOT 2
- Open a file in a new tab HOT 5
- Optionally populate location/quickfix list HOT 3
- Edit mode HOT 3
- [Question] Mapping :Ags HOT 1
- Can't cancel long searches HOT 1
- Can't open files from search results
- Add folding markers
- Search results on new MacBook includes color encodings HOT 1
- file name encoding problem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-ags.